use pubsub instead of filenotify to follow json logs
inotify event is trigged immediately there's data written to disk. But at the time that the inotify event is received, the json line might not fully saved to disk. If the json decoder tries to decode in such case, an io.UnexpectedEOF will be trigged. We used to retry for several times to mitigate the io.UnexpectedEOF error. But there are still flaky tests caused by the partial log entries. The daemon knows exactly when there are new log entries emitted. We can use the pubsub package to notify all the log readers instead of inotify. Signed-off-by: Shijiang Wei <mountkin@gmail.com> try to fix broken test. will squash once tests pass Signed-off-by: Shijiang Wei <mountkin@gmail.com>
This commit is contained in:
parent
e178bdf28e
commit
092f2d6aed
1 changed files with 4 additions and 2 deletions
|
@ -54,8 +54,10 @@ func (p *Publisher) SubscribeTopic(topic topicFunc) chan interface{} {
|
|||
// Evict removes the specified subscriber from receiving any more messages.
|
||||
func (p *Publisher) Evict(sub chan interface{}) {
|
||||
p.m.Lock()
|
||||
delete(p.subscribers, sub)
|
||||
close(sub)
|
||||
if _, ok := p.subscribers[sub]; ok {
|
||||
delete(p.subscribers, sub)
|
||||
close(sub)
|
||||
}
|
||||
p.m.Unlock()
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue