func (_tailer *Tailer) loop() { transcript.TraceDebugging("running tailer...") var _error error var _offset int64 transcript.TraceDebugging("opening tailer file...") _tailer.file, _error = os.Open(_tailer.path) if _error != nil { transcript.TraceError("error encountered while opening tailer file; aborting...") panic(_error) } defer _tailer.file.Close() _offset, _error = _tailer.file.Seek(0, os.SEEK_END) if _error != nil { transcript.TraceWarning("error encountered while positioning tailer file; ignoring...") } _tailer.pushIdentifier, _tailer.pushChannel = _tailer.router.CreateInbound() defer _tailer.router.UnregisterInbound(_tailer.pushIdentifier) _reader := bufio.NewReader(_tailer.file) for _counter := 0; ; _counter += 1 { _line, _error := _reader.ReadBytes('\n') if _error == io.EOF { time.Sleep(100 * time.Millisecond) continue } if _error != nil { transcript.TraceError("error encountered while reading tailer file; aborting...") panic(_error) } if (_counter == 0) && (_offset != 0) { continue } _tailer.pushChannel <- Event{Payload: _line} } }
func (_router *router) handleEvent(_event Event) { transcript.TraceDebugging("routing event...") for _, _channel := range _router.outboundChannels { select { case _channel <- _event: default: transcript.TraceWarning("channel buffer overflow...") } } }