Skip to content

Commit

Permalink
Implement check-in scheduler
Browse files Browse the repository at this point in the history
Implement a check-in event scheduler, which schedules check-in events
to be transmitted in a separate thread, with a minimum wait period
of ten seconds between requests, and a wait period of a tenth of a
second before the first request, referred to as "debounce" periods.

This is a relatively minor improvement for the existing cron
check-ins, but it is a requirement for the heartbeat check-ins, both
to avoid slowing down customers' applications with blocking requests,
and to avoid misuse of the feature from spamming our servers.

The scheduler also acts as a deduplicator, removing "similar enough"
check-in events -- again, not particularly interesting for cron
check-ins, but a requirement to minimise damage when heartbeat
check-ins are misused.

Implement utility functions for serialising and deserialising NDJSON
payloads.

When an event is scheduled, the scheduler sets a timeout for the
duration of the timeout period, after which the events stored in
the scheduler are transmitted.

When `Appsignal.stop` is called and awaited, the scheduler is
gracefully stopped, awaiting the transmission of all scheduled
check-in events. During this time, new check-in events cannot be
scheduled.
  • Loading branch information
unflxw committed Sep 5, 2024
1 parent 5f600d9 commit a61d16b
Show file tree
Hide file tree
Showing 10 changed files with 649 additions and 262 deletions.
6 changes: 6 additions & 0 deletions .changesets/check-in-scheduler.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
bump: patch
type: change
---

Send check-ins concurrently. When calling `Appsignal.checkIn.cron`, instead of blocking the current process while the check-in events are sent, schedule them to be sent in a separate process.
Loading

0 comments on commit a61d16b

Please sign in to comment.