Class: JobWorkflow::TaskThrottle
- Inherits:
-
Object
- Object
- JobWorkflow::TaskThrottle
- Defined in:
- lib/job_workflow/task_throttle.rb
Instance Attribute Summary collapse
-
#key ⇒ Object
readonly
: String.
-
#limit ⇒ Object
readonly
: Integer?.
-
#ttl ⇒ Object
readonly
: Integer.
Class Method Summary collapse
-
.from_primitive_value_with_task(value:, task:) ⇒ Object
: (value: Integer | Hash[Symbol, untyped], task: Task) -> TaskThrottle.
Instance Method Summary collapse
-
#initialize(key:, limit: nil, ttl: 180) ⇒ TaskThrottle
constructor
: (key: String, ?limit: Integer?, ?ttl: Integer) -> void.
-
#semaphore ⇒ Object
: () -> Semaphore?.
Constructor Details
#initialize(key:, limit: nil, ttl: 180) ⇒ TaskThrottle
: (key: String, ?limit: Integer?, ?ttl: Integer) -> void
28 29 30 31 32 |
# File 'lib/job_workflow/task_throttle.rb', line 28 def initialize(key:, limit: nil, ttl: 180) @key = key @limit = limit @ttl = ttl end |
Instance Attribute Details
#key ⇒ Object (readonly)
: String
5 6 7 |
# File 'lib/job_workflow/task_throttle.rb', line 5 def key @key end |
#limit ⇒ Object (readonly)
: Integer?
6 7 8 |
# File 'lib/job_workflow/task_throttle.rb', line 6 def limit @limit end |
#ttl ⇒ Object (readonly)
: Integer
7 8 9 |
# File 'lib/job_workflow/task_throttle.rb', line 7 def ttl @ttl end |
Class Method Details
.from_primitive_value_with_task(value:, task:) ⇒ Object
: (value: Integer | Hash[Symbol, untyped], task: Task) -> TaskThrottle
11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/job_workflow/task_throttle.rb', line 11 def from_primitive_value_with_task(value:, task:) case value when Integer new(key: task.throttle_prefix_key, limit: value) when Hash new( key: value[:key] || task.throttle_prefix_key, limit: value[:limit], ttl: value[:ttl] || 180 ) else raise ArgumentError, "throttle must be Integer or Hash" end end |