Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

source-gladly: don't emit a checkpoint with no documents every time #1319

Merged
merged 1 commit into from
Mar 5, 2024
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
9 changes: 9 additions & 0 deletions source-gladly/source_gladly/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,15 @@ async def fetch_events(
f"not updating cursor since last_ts ({last_ts}) <= log_cursor ({log_cursor})"
)
return
elif last_ts - log_cursor < timedelta(hours=6):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: i suspect this control flow could be cleaned up further, but this is correct 🤷

# Only emit an updated checkpoint when there are no documents if the current cursor is
# sufficiently old. Emitting a checkpoint with no documents will trigger an immediate
# re-invocation of this task, so it shouldn't be done every time.
log.debug(
f"not updating cursor since updated cursor is less than 6 hours newer than prior cursor (updated cursor: {last_ts} vs prior cursor: {log_cursor})"
)
return

else:
# The Events API has millisecond precision for timestamps, so bump up the log cursor one
# millisecond to not re-fetch the last event seen again on the next round. The assumption
Expand Down
Loading