I've been wondering... Why not allow receive some configurations on initialize method?
Today:
def with_ratelimit(&block)
ratelimit = Ratelimit.new("whatsapp", { bucket_interval: BUCKET_INTERVAL })
ratelimit.exec_within_threshold('send_message', threshold: THRESHOLD, interval: INTERVAL) do
ratelimit.add('send_message')
yield
end
end
Desire:
def with_ratelimit(&block)
opts = { bucket_interval: BUCKET_INTERVAL, threshold: THRESHOLD, interval: INTERVAL}
Ratelimit.new("whatsapp::send_message", opts).exec_within_threshold do
# doesnt need to use add method anymore
yield
end
end
I can implement this modification if you agree, what do you think?
Sorry for the delay. This looks good to me. My only concern is changing the bucket interval between calls to the same key might yield strange results. We'd just need to test for that.
I've been wondering... Why not allow receive some configurations on initialize method?
Today:
Desire:
I can implement this modification if you agree, what do you think?