Conversation
lucab
left a comment
There was a problem hiding this comment.
Thanks for the PR!
While the features seem useful, the implementation of FollowTail especially may need a bit of re-design.
Also, I'd be happy if this can be covered by some basic test just for sanity.
| } | ||
|
|
||
| // SkipN skips the next n entries and returns the number of skipped entries and an eventual error. | ||
| func (r *JournalReader) SkipN(n int) (int, error) { |
There was a problem hiding this comment.
I think it may be useful here to check that n >= 0.
sdjournal/read.go
Outdated
| // SkipN skips the next n entries and returns the number of skipped entries and an eventual error. | ||
| func (r *JournalReader) SkipN(n int) (int, error) { | ||
| var i int | ||
| for i := 1; i <= n; i++ { |
There was a problem hiding this comment.
Just curious, why doesn't this start at i := 0? Let's maybe change to that, as it may be less surprising to read, right?
There was a problem hiding this comment.
Didn't notice until you mentioned it, but it really looks kind of messy! Thanks.
sdjournal/read.go
Outdated
|
|
||
| // 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) error { |
There was a problem hiding this comment.
I'm not overly positive with this proposed signature, as it lacks at least a Context to cancel the inner looping logic.
Additionally, I'm wondering whether it is better to return two channels (entries and err) so that the whole follow-tailing logic can be handled asynchronously.
|
Thanks a lot for your suggestions @lucab! I implemented some of them already and will come back for the rest soon. Especially enabling better asynchronous behaviour of the FollowTail method will surely increase the number of possible use cases. |
First, thanks a lot for providing this interface to systemd, I currently use it to synchronise the journal of multiple devices with an external remote.
The recent follow method didn't work as I wanted it for my use case to due to various reasons: