Class: Resque::Plugins::Logstash::Transport::Redis
- Inherits:
-
Object
- Object
- Resque::Plugins::Logstash::Transport::Redis
- Defined in:
- lib/resque/logstash/transport/redis.rb
Instance Attribute Summary collapse
-
#key ⇒ Object
readonly
Returns the value of attribute key.
Instance Method Summary collapse
- #host ⇒ Object
-
#initialize(host, port = nil, key = 'logstash') ⇒ Redis
constructor
A new instance of Redis.
- #initialize_with_keyword_arguments(key: 'logstash', redis: nil, **redis_options) ⇒ Object
- #port ⇒ Object
- #push(value) ⇒ Object
- #redis ⇒ Object
Constructor Details
#initialize(host, port = nil, key = 'logstash') ⇒ Redis
Returns a new instance of Redis.
5 6 7 8 9 10 11 12 |
# File 'lib/resque/logstash/transport/redis.rb', line 5 def initialize(host, port = nil, key = 'logstash') if host.is_a?(Hash) initialize_with_keyword_arguments(host) else @redis_options = { host: host, port: port } @key = key end end |
Instance Attribute Details
#key ⇒ Object (readonly)
Returns the value of attribute key.
24 25 26 |
# File 'lib/resque/logstash/transport/redis.rb', line 24 def key @key end |
Instance Method Details
#host ⇒ Object
30 31 32 |
# File 'lib/resque/logstash/transport/redis.rb', line 30 def host @redis_options[:host] end |
#initialize_with_keyword_arguments(key: 'logstash', redis: nil, **redis_options) ⇒ Object
14 15 16 17 18 19 20 21 22 |
# File 'lib/resque/logstash/transport/redis.rb', line 14 def initialize_with_keyword_arguments(key: 'logstash', redis: nil, **) @key = key if redis @redis = redis else @redis_options = end end |
#port ⇒ Object
34 35 36 |
# File 'lib/resque/logstash/transport/redis.rb', line 34 def port @redis_options[:port] end |
#push(value) ⇒ Object
38 39 40 |
# File 'lib/resque/logstash/transport/redis.rb', line 38 def push(value) redis.rpush @key, value.to_json end |
#redis ⇒ Object
26 27 28 |
# File 'lib/resque/logstash/transport/redis.rb', line 26 def redis @redis ||= ::Redis.new(@redis_options) end |