Class: Bluecollar::Client
- Inherits:
-
Object
- Object
- Bluecollar::Client
- Defined in:
- lib/bluecollar-client/client.rb
Class Attribute Summary collapse
-
.configuration ⇒ Object
readonly
Returns the value of attribute configuration.
-
.instance ⇒ Object
readonly
Returns the value of attribute instance.
-
.logger ⇒ Object
readonly
Returns the value of attribute logger.
Instance Attribute Summary collapse
-
#redis_db ⇒ Object
Returns the value of attribute redis_db.
-
#redis_hostname ⇒ Object
Returns the value of attribute redis_hostname.
-
#redis_key_prefix ⇒ Object
Returns the value of attribute redis_key_prefix.
-
#redis_port ⇒ Object
Returns the value of attribute redis_port.
-
#redis_timeout ⇒ Object
Returns the value of attribute redis_timeout.
Class Method Summary collapse
Instance Method Summary collapse
Class Attribute Details
.configuration ⇒ Object (readonly)
Returns the value of attribute configuration.
8 9 10 |
# File 'lib/bluecollar-client/client.rb', line 8 def configuration @configuration end |
.instance ⇒ Object (readonly)
Returns the value of attribute instance.
8 9 10 |
# File 'lib/bluecollar-client/client.rb', line 8 def instance @instance end |
.logger ⇒ Object (readonly)
Returns the value of attribute logger.
8 9 10 |
# File 'lib/bluecollar-client/client.rb', line 8 def logger @logger end |
Instance Attribute Details
#redis_db ⇒ Object
Returns the value of attribute redis_db.
4 5 6 |
# File 'lib/bluecollar-client/client.rb', line 4 def redis_db @redis_db end |
#redis_hostname ⇒ Object
Returns the value of attribute redis_hostname.
4 5 6 |
# File 'lib/bluecollar-client/client.rb', line 4 def redis_hostname @redis_hostname end |
#redis_key_prefix ⇒ Object
Returns the value of attribute redis_key_prefix.
4 5 6 |
# File 'lib/bluecollar-client/client.rb', line 4 def redis_key_prefix @redis_key_prefix end |
#redis_port ⇒ Object
Returns the value of attribute redis_port.
4 5 6 |
# File 'lib/bluecollar-client/client.rb', line 4 def redis_port @redis_port end |
#redis_timeout ⇒ Object
Returns the value of attribute redis_timeout.
4 5 6 |
# File 'lib/bluecollar-client/client.rb', line 4 def redis_timeout @redis_timeout end |
Class Method Details
.configure(options = {}) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/bluecollar-client/client.rb', line 10 def configure( = {}) @instance = nil @logger = [:logger] || Logger.new("/dev/null") @configuration = {} @configuration[:redis_key_prefix] = [:redis_key_prefix] || "bluecollar" @configuration[:redis_hostname] = [:redis_hostname] || "127.0.0.1" @configuration[:redis_port] = ([:redis_port] || 6379).to_i @configuration[:redis_db] = [:redis_db].to_i @configuration[:redis_timeout] = ([:redis_timeout] || 5000).to_i end |
Instance Method Details
#async_job_for(worker_name, args) ⇒ Object
28 29 30 31 32 33 |
# File 'lib/bluecollar-client/client.rb', line 28 def async_job_for(worker_name, args) redis_connection.lpush processing_queue, redis_payload(worker_name, args) rescue Redis::BaseError => e Bluecollar::Client.logger.warn("Error while adding #{worker_name}: #{args.inspect} to queue.\n#{e}:#{e.message}\nBacktrace:\n\t#{e.backtrace.join("\n\t")}") raise Bluecollar::ClientError.new("Error while adding #{worker_name}: #{args.inspect} to queue.\n#{e}:#{e.message}\nBacktrace:\n\t#{e.backtrace.join("\n\t")}") end |