Skip to content

Commit 263c6a1

Browse files
committed
FollowTail: change return of "error" to channel of "error"
1 parent 56bddae commit 263c6a1

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

sdjournal/read.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -278,14 +278,14 @@ func (r *JournalReader) SkipN(n int) (int, error) {
278278

279279
// FollowTail synchronously follows the JournalReader, writing each new journal entry to entries.
280280
// It will start from the next unread entry.
281-
func (r *JournalReader) FollowTail(entries chan *JournalEntry, ctx context.Context) error {
281+
func (r *JournalReader) FollowTail(entries chan<- *JournalEntry, errors chan<- error, ctx context.Context) {
282282
defer close(entries)
283283

284284
for {
285285
select {
286286
case <-ctx.Done():
287287
fmt.Println("Context done, exit FollowTail")
288-
return nil
288+
return
289289
default:
290290
}
291291

@@ -296,14 +296,14 @@ func (r *JournalReader) FollowTail(entries chan *JournalEntry, ctx context.Conte
296296

297297
for {
298298
if c, err := r.journal.Next(); err != nil {
299-
return err
299+
errors <- err
300300
} else if c == 0 {
301301
// EOF, should mean we're at the tail
302302
break
303303
}
304304

305305
if entry, err := r.journal.GetEntry(); err != nil {
306-
return err
306+
errors <- err
307307
} else {
308308
entries <- entry
309309
}

0 commit comments

Comments
 (0)