Class: DistributedJob::Client
- Inherits:
-
Object
- Object
- DistributedJob::Client
- Defined in:
- lib/distributed_job/client.rb
Overview
A DistributedJob::Client allows to easily manage distributed jobs. The
main purpose of the client object is to configure settings to all
distributed jobs or a group of distributed jobs like e.g. the redis
connection and an optional namespace to be used to prefix all redis keys.
Instance Attribute Summary collapse
-
#default_ttl ⇒ Object
readonly
Returns the value of attribute default_ttl.
-
#namespace ⇒ Object
readonly
Returns the value of attribute namespace.
-
#redis ⇒ Object
readonly
Returns the value of attribute redis.
Instance Method Summary collapse
-
#build(token:, ttl: default_ttl) ⇒ Object
Builds a new
DistributedJob::Jobinstance. -
#initialize(redis:, namespace: nil, default_ttl: 86_400) ⇒ Client
constructor
Creates a new
DistributedJob::Client.
Constructor Details
#initialize(redis:, namespace: nil, default_ttl: 86_400) ⇒ Client
Creates a new DistributedJob::Client.
36 37 38 39 40 |
# File 'lib/distributed_job/client.rb', line 36 def initialize(redis:, namespace: nil, default_ttl: 86_400) @redis = redis @namespace = namespace @default_ttl = default_ttl end |
Instance Attribute Details
#default_ttl ⇒ Object (readonly)
Returns the value of attribute default_ttl.
22 23 24 |
# File 'lib/distributed_job/client.rb', line 22 def default_ttl @default_ttl end |
#namespace ⇒ Object (readonly)
Returns the value of attribute namespace.
22 23 24 |
# File 'lib/distributed_job/client.rb', line 22 def namespace @namespace end |
#redis ⇒ Object (readonly)
Returns the value of attribute redis.
22 23 24 |
# File 'lib/distributed_job/client.rb', line 22 def redis @redis end |
Instance Method Details
#build(token:, ttl: default_ttl) ⇒ Object
Builds a new DistributedJob::Job instance.
51 52 53 |
# File 'lib/distributed_job/client.rb', line 51 def build(token:, ttl: default_ttl) Job.new(client: self, token: token, ttl: ttl) end |