Class: WSDirector::Task
- Inherits:
-
Object
- Object
- WSDirector::Task
- Defined in:
- lib/wsdirector/task.rb
Overview
Single client operator
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#global_holder ⇒ Object
readonly
Returns the value of attribute global_holder.
Instance Method Summary collapse
-
#initialize(config, id:, global_holder:, result:, scale:, logger:, colorize: false) ⇒ Task
constructor
A new instance of Task.
- #run(url) ⇒ Object
- #sampled?(step) ⇒ Boolean
Constructor Details
#initialize(config, id:, global_holder:, result:, scale:, logger:, colorize: false) ⇒ Task
Returns a new instance of Task.
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/wsdirector/task.rb', line 11 def initialize(config, id:, global_holder:, result:, scale:, logger:, colorize: false) @id = id @logger = logger @ignore = config.fetch("ignore") @steps = config.fetch("steps") @connection_options = config.fetch("connection_options").transform_keys(&:to_sym) @global_holder = global_holder @result = result protocol_class = Protocols.get(config.fetch("protocol", "base")) @protocol = protocol_class.new(self, scale:, logger:, id:, color: color_for_id(id, colorize)) end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
9 10 11 |
# File 'lib/wsdirector/task.rb', line 9 def client @client end |
#global_holder ⇒ Object (readonly)
Returns the value of attribute global_holder.
9 10 11 |
# File 'lib/wsdirector/task.rb', line 9 def global_holder @global_holder end |
Instance Method Details
#run(url) ⇒ Object
24 25 26 27 28 29 30 31 32 |
# File 'lib/wsdirector/task.rb', line 24 def run(url) connect!(url, **@connection_options) steps.each(&protocol) result.succeed rescue Error => e result.failed(e.) end |
#sampled?(step) ⇒ Boolean
34 35 36 37 38 39 40 |
# File 'lib/wsdirector/task.rb', line 34 def sampled?(step) return true unless step["sample"] id, max = step["id"], step["sample"] result.track_sample(id, max) end |