Skip to content

Commit

Permalink
update(sdk): apply code review suggestions
Browse files Browse the repository at this point in the history
Signed-off-by: Jason Dellaluce <jasondellaluce@gmail.com>

Co-authored-by: Leonardo Grasso <me@leonardograsso.com>
  • Loading branch information
2 people authored and poiana committed Jun 13, 2022
1 parent c7d7e44 commit 34708af
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions pkg/sdk/plugins/source/instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,9 @@ func (s *pullInstance) NextBatch(pState sdk.PluginState, evts sdk.EventWriters)

// pull a new event
if err = s.pull(s.ctx, evts.Get(n)); err != nil {
if err == sdk.ErrEOF {
s.eof = true
}
return
}
n++
Expand All @@ -215,7 +218,7 @@ func (s *pullInstance) NextBatch(pState sdk.PluginState, evts sdk.EventWriters)
return n, nil
}

// PushEvent represents an event produced from an event source with pull model.
// PushEvent represents an event produced from an event source with the push model.
//
// If the event source produced the event successfully, then Data must be non-nil
// and Err must be ni. If the event source encountered a failure, Data must be
Expand Down Expand Up @@ -321,7 +324,9 @@ func (s *pushInstance) NextBatch(pState sdk.PluginState, evts sdk.EventWriters)
return n, evt.Err
}
// event added to the batch successfully
if !evt.Timestamp.IsZero() {
if evt.Timestamp.IsZero() {
evts.Get(n).SetTimestamp(math.MaxUint64)
} else {
evts.Get(n).SetTimestamp(uint64(evt.Timestamp.UnixNano()))
}
n++
Expand Down

0 comments on commit 34708af

Please sign in to comment.