Class: Fluent::SidekiqOutput
- Inherits:
-
BufferedOutput
- Object
- BufferedOutput
- Fluent::SidekiqOutput
- Defined in:
- lib/fluent/plugin/out_sidekiq.rb
Constant Summary collapse
- VERSION =
"0.0.2"
Instance Method Summary collapse
- #format(tag, time, record) ⇒ Object
- #redis_client ⇒ Object
- #shutdown ⇒ Object
- #start ⇒ Object
- #write(chunk) ⇒ Object
Instance Method Details
#format(tag, time, record) ⇒ Object
18 19 20 |
# File 'lib/fluent/plugin/out_sidekiq.rb', line 18 def format(tag, time, record) [tag, time, record].to_msgpack end |
#redis_client ⇒ Object
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/fluent/plugin/out_sidekiq.rb', line 22 def redis_client opts = {url: @redis_url} client = Redis.new(opts) if @redis_namespace require "redis/namespace" Redis::Namespace.new(@redis_namespace, client) else client end end |
#shutdown ⇒ Object
14 15 16 |
# File 'lib/fluent/plugin/out_sidekiq.rb', line 14 def shutdown super end |
#start ⇒ Object
10 11 12 |
# File 'lib/fluent/plugin/out_sidekiq.rb', line 10 def start super end |
#write(chunk) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/fluent/plugin/out_sidekiq.rb', line 33 def write(chunk) client = redis_client client.pipelined do chunk.msgpack_each do |tag, time, data| at = data.delete('at') if at client.zadd('schedule', [at, data['payload']]) else queue = data.delete('queue') client.sadd('queues', queue) client.lpush("queue:#{queue}", data['payload']) end end end end |