Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions lib/backend/dynamo/shards.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,8 @@ func (b *Backend) pollStreams(externalCtx context.Context) error {
b.buf.SetInit()
defer b.buf.Reset()

ticker := time.NewTicker(b.PollStreamPeriod)
defer ticker.Stop()
timer := time.NewTimer(b.PollStreamPeriod)
defer timer.Stop()

for {
select {
Expand All @@ -174,10 +174,11 @@ func (b *Backend) pollStreams(externalCtx context.Context) error {
} else {
b.buf.Emit(event.events...)
}
case <-ticker.C:
case <-timer.C:
if err := refreshShards(false); err != nil {
return trace.Wrap(err)
}
timer.Reset(b.PollStreamPeriod)
case <-ctx.Done():
b.logger.Log(ctx, logutils.TraceLevel, "Context is closing, returning.")
return nil
Expand Down Expand Up @@ -281,6 +282,12 @@ func (b *Backend) collectActiveShards(ctx context.Context, streamArn *string) ([
return filterActiveShards(out), nil
}
input.ExclusiveStartShardId = streamInfo.StreamDescription.LastEvaluatedShardId
select {
case <-ctx.Done():
// let the next call deal with the context error
case <-time.After(200 * time.Millisecond):
// 10 calls per second with two auths, with ample margin
}
}
}

Expand Down
Loading