Class: Textus::Store::Jobs::Queue::Job
- Inherits:
-
Object
- Object
- Textus::Store::Jobs::Queue::Job
- Defined in:
- lib/textus/store/jobs/queue.rb
Constant Summary collapse
- DIGEST_BYTES =
16
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#attempts ⇒ Object
readonly
Returns the value of attribute attempts.
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
-
#max_attempts ⇒ Object
readonly
Returns the value of attribute max_attempts.
-
#role ⇒ Object
readonly
Returns the value of attribute role.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #id ⇒ Object
-
#initialize(type:, args:, role:, attempts: 0, max_attempts: 3, errors: []) ⇒ Job
constructor
A new instance of Job.
Constructor Details
#initialize(type:, args:, role:, attempts: 0, max_attempts: 3, errors: []) ⇒ Job
Returns a new instance of Job.
21 22 23 24 25 26 27 28 |
# File 'lib/textus/store/jobs/queue.rb', line 21 def initialize(type:, args:, role:, attempts: 0, max_attempts: 3, errors: []) @type = type.to_s @args = stringify(args) @role = role.to_s @attempts = attempts.to_i @max_attempts = max_attempts.to_i @errors = Array(errors) end |
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
19 20 21 |
# File 'lib/textus/store/jobs/queue.rb', line 19 def args @args end |
#attempts ⇒ Object (readonly)
Returns the value of attribute attempts.
19 20 21 |
# File 'lib/textus/store/jobs/queue.rb', line 19 def attempts @attempts end |
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
19 20 21 |
# File 'lib/textus/store/jobs/queue.rb', line 19 def errors @errors end |
#max_attempts ⇒ Object (readonly)
Returns the value of attribute max_attempts.
19 20 21 |
# File 'lib/textus/store/jobs/queue.rb', line 19 def max_attempts @max_attempts end |
#role ⇒ Object (readonly)
Returns the value of attribute role.
19 20 21 |
# File 'lib/textus/store/jobs/queue.rb', line 19 def role @role end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
19 20 21 |
# File 'lib/textus/store/jobs/queue.rb', line 19 def type @type end |
Instance Method Details
#id ⇒ Object
30 31 32 |
# File 'lib/textus/store/jobs/queue.rb', line 30 def id "#{type}:#{Digest::SHA256.hexdigest(JSON.dump(args.sort.to_h))[0, DIGEST_BYTES]}" end |