module ClockLookupThrottle
ClockLookupThrottle — rate-limit external clock flip lookups (Urban, Wikipedia). Public: allowed?, record! Depends: RabbotDb Tests: test/lib/clock_lookup_throttle_test.rb
Constants
- KEY
- MIN_GAP_SEC
- PLUGIN
Public Instance Methods
Source
# File lib/clock/lookup_throttle.rb, line 17 def allowed?(store: RabbotDb, now: Time.now, min_gap_sec: MIN_GAP_SEC) last_at = RabbotDb.parse_time(store.get_plugin_value(plugin: PLUGIN, key: KEY)) return true unless last_at (now - last_at) >= min_gap_sec end
Source
# File lib/clock/lookup_throttle.rb, line 24 def record!(store: RabbotDb, now: Time.now) store.set_plugin_value( plugin: PLUGIN, key: KEY, value: RabbotDb.iso_time(now) ) end