This is a re-implementation of the throttling logic introduced in v0.4.0 via #20, but implemented as a decorator module.
The throttling configuration syntax is concise:
class RateLimitedJob < Mosquito::QueuedJob
include Mosquito::RateLimiter
throttle limit: 1, per: 10.seconds
params blah : Int32
def perform
# etc...
end
end
Highlights:
Leverages before hook introduced in 7de390cf160756c16cbd360975786fb4fc698b66 (v0.11.1) so the interface is transparent, and doesn't have any performance penalty on jobs which don't need rate limiting.
Leverages metadata store introduced in ae67378f9b7c5acaee60fb7df36816e26ea09a8c. The rate limit configuration logic is no longer dangling off of Queue.
The rate limit key is now override-able, which means that multiple jobs can share the same rate limit counters. This hopefully will be useful for guarding against 3rd api usage guidelines.
Ancillary improvements:
Implements after hooks, by copying and pasting the before hook code and tests.
Extends metadata#increment to allow passing in an increment value.
Fixes a latent bug where false could not be set as the default value for a job parameter.
This is a re-implementation of the throttling logic introduced in v0.4.0 via #20, but implemented as a decorator module.
The throttling configuration syntax is concise:
Highlights:
before
hook introduced in 7de390cf160756c16cbd360975786fb4fc698b66 (v0.11.1) so the interface is transparent, and doesn't have any performance penalty on jobs which don't need rate limiting.Ancillary improvements:
after
hooks, by copying and pasting thebefore
hook code and tests.false
could not be set as the default value for a job parameter.