-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add (and use) conditional fillup (#12)
For some features - such as "deliver this message at most once" - you need to be able to tell whether a leaky bucket has accepted a topup or not. This is especially treacherous when the bucket has capacity of 1. Observe: * A bucket of `capacity=1` gets configured for a specific leak rate (say, `over_time=1` for 1 second * The bucket gets incremented by 1 (one message should be delivered) * The result is that the bucket "did fill up", so the caller will suppress the message (to the caller it looks like the bucket is already full) The proper way to deal with this is to have "compare and set" semantics instead: * A bucket of `capacity=1` gets configured for a specific leak rate (say, `over_time=1` for 1 second * The bucket gets incremented by 1 (one message should be delivered). The caller gets both the achieved level (`1`) and a flag indicating that the bucket _did_ in fact accept the write * The caller delivers the "once per second" message * On second call, after 0.5 seconds, the caller tries to fillup with `1` and gets the the achieved level (which remains `~0.5` because no write was granted) and a flag indicating that the write was rejected For this we need to juggle some SQL around, but there is nothing making this impossible.
- Loading branch information
Showing
10 changed files
with
332 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.