File tree Expand file tree Collapse file tree 1 file changed +14
-5
lines changed Expand file tree Collapse file tree 1 file changed +14
-5
lines changed Original file line number Diff line number Diff line change @@ -256,16 +256,25 @@ process:
256256 }
257257}
258258
259+ // SkipN skips the next n entries and returns the number of skipped entries and an eventual error.
260+ func (r * JournalReader ) SkipN (n int ) (int , error ) {
261+ var i int
262+ for i := 1 ; i <= n ; i ++ {
263+ c , err := r .journal .Next ()
264+ if err != nil {
265+ return i , err
266+ } else if c == 0 {
267+ return i , nil
268+ }
269+ }
270+ return i , nil
271+ }
272+
259273// FollowTail synchronously follows the JournalReader, writing each new journal entry to entries.
260274// It will start from the next unread entry.
261275func (r * JournalReader ) FollowTail (entries chan * JournalEntry ) error {
262276 defer close (entries )
263277
264- // skip first entry which has already been read
265- if _ , err := r .journal .Next (); err != nil {
266- return err
267- }
268-
269278 for {
270279 status := r .journal .Wait (200 * time .Millisecond )
271280 if status != SD_JOURNAL_APPEND && status != SD_JOURNAL_INVALIDATE {
You can’t perform that action at this time.
0 commit comments