func (this *worker) run(fn string) { reader := als.NewAlsReader(fn) if err := reader.Open(); err != nil { panic(err) } defer func() { this.wg.Done() reader.Close() }() var ( line []byte err error snsid interface{} msg = als.NewAlsMessage() ) for { line, err = reader.ReadLine() if err != nil { break } else { msg.FromLine(string(line)) snsid, err = msg.FieldValue("_log_info.snsid", als.KEY_TYPE_STRING) if err != nil { continue } fetchAvatar(msg.Area, snsid.(string)) } } }
func (this *worker) run(fn string) { reader := als.NewAlsReader(fn) if err := reader.Open(); err != nil { panic(err) } defer func() { this.wg.Done() reader.Close() }() var ( line []byte err error present bool elapsed interface{} msg = als.NewAlsMessage() ) for { line, err = reader.ReadLine() if err != nil { break } else { msg.FromLine(string(line)) elapsed, err = msg.FieldValue("_log_info.elapsed", als.KEY_TYPE_FLOAT) if err != nil { continue } if _, present = quants[msg.Area]; present { quants[msg.Area].Insert(elapsed.(float64)) } } } }
func (this *ArchiveInput) doRunSingleLogfile(path string) { reader := als.NewAlsReader(path) if e := reader.Open(); e != nil { panic(e) } defer func() { reader.Close() this.workersWg.Done() atomic.AddInt32(&this.leftN, -1) <-this.workerNChan // release the lock }() var ( line []byte lineN int inChan = this.runner.InChan() err error project = this.h.Project(this.project) pack *engine.PipelinePack globals = engine.Globals() ) for !this.stopping { line, err = reader.ReadLine() switch err { case nil: lineN += 1 atomic.AddInt64(&this.lineN, 1) if globals.Verbose && lineN == 1 { project.Printf("[%s]started\n", path) } pack = <-inChan if err = pack.Message.FromLine(string(line)); err != nil { if project.ShowError && err != als.ErrEmptyLine { project.Printf("[%s]%v: %s", path, err, string(line)) } pack.Recycle() continue } pack.Ident = this.ident pack.Project = this.project pack.Logfile.SetPath(path) if globals.Debug { globals.Println(*pack) } this.runner.Inject(pack) case io.EOF: if globals.Verbose { project.Printf("[%s]done, lines: %d\n", path, lineN) } this.chkpnt.Put(path) this.chkpnt.Dump() return default: // unknown error panic(err) } } }