module Hutch::Schedule
Hutch::Schedule
, just an addon to deal with the schedule exchange. If you want use it, just do `Hutch::Schedule.connect(Hutch.broker)` to initialize it and then just use like Hutch
to publish message `Hutch::Schedule.publish`
Constants
- DELAY_QUEUES
fixed delay levels seconds(4): 5s, 10s, 20s, 30s minutes(14): 1m, 2m, 3m, 4m, 5m, 6m, 7m, 8m, 9m, 10m, 20m, 30m, 40m, 50m hours(3): 1h, 2h, 3h
- VERSION
Public Class Methods
connect()
click to toggle source
# File lib/hutch/schedule.rb, line 29 def connect ActiveJob::QueueAdapters::HutchAdapter.register_actice_job_classes if defined?(ActiveJob::QueueAdapters::HutchAdapter) return if core.present? Hutch.connect @core = Hutch::Schedule::Core.new(Hutch.broker) @core.connect! end
core()
click to toggle source
# File lib/hutch/schedule.rb, line 43 def core @core end
delay_queue_name(suffix)
click to toggle source
# File lib/hutch/schedule.rb, line 74 def delay_queue_name(suffix) "#{Hutch::Config.get(:mq_exchange)}_delay_queue_#{suffix}" end
delay_routing_key(suffix)
click to toggle source
fixed delay level queue's routing_key
# File lib/hutch/schedule.rb, line 70 def delay_routing_key(suffix) "#{Hutch::Config.get(:mq_exchange)}.schedule.#{suffix}" end
disconnect()
click to toggle source
# File lib/hutch/schedule.rb, line 38 def disconnect Hutch.disconnect if Hutch.connected? @core = nil end
ns()
click to toggle source
redis with namespace
# File lib/hutch/schedule.rb, line 48 def ns @redis ||= Redis::Namespace.new(:hutch, redis: Redis.new( url: Hutch::Config.get(:redis_url), # https://github.com/redis/redis-rb#reconnections # retry 10 times total cost 10 * 30 = 300s reconnect_attempts: Hutch::Config.get(:ratelimit_redis_reconnect_attempts), :reconnect_delay => 3, :reconnect_delay_max => 30.0, )) end
publish(*args)
click to toggle source
# File lib/hutch/schedule.rb, line 65 def publish(*args) core.publish(*args) end
redis()
click to toggle source
all Consumers that use threshold module shared the same redis instance
# File lib/hutch/schedule.rb, line 60 def redis ns.redis end