Skip to content

Commit

Permalink
FollowTail: change return of "error" to channel of "error"
Browse files Browse the repository at this point in the history
  • Loading branch information
nexoscp committed Aug 25, 2022
1 parent 56bddae commit 263c6a1
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions sdjournal/read.go
Original file line number Diff line number Diff line change
Expand Up @@ -278,14 +278,14 @@ func (r *JournalReader) SkipN(n int) (int, error) {

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

for {
select {
case <-ctx.Done():
fmt.Println("Context done, exit FollowTail")
return nil
return
default:
}

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

for {
if c, err := r.journal.Next(); err != nil {
return err
errors <- err
} else if c == 0 {
// EOF, should mean we're at the tail
break
}

if entry, err := r.journal.GetEntry(); err != nil {
return err
errors <- err
} else {
entries <- entry
}
Expand Down

0 comments on commit 263c6a1

Please sign in to comment.