Class: OpsDeploy::Waiter

Inherits:
Thread
  • Object
show all
Defined in:
lib/ops_deploy/waiter.rb

Direct Known Subclasses

DeploymentWaiter, InstanceResponseWaiter

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(&task) ⇒ Waiter

Returns a new instance of Waiter.



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/ops_deploy/waiter.rb', line 4

def initialize(&task)
  @task = task

  super() {
    error = nil

    begin
      until false
        @data = @task.call
        break if @end_when.call(@data)
        sleep 5
      end
    rescue StandardError => e
      error = e
    end

    @callback.call(@data, error) if @callback

    @data
  }
end

Instance Attribute Details

#callbackObject

Returns the value of attribute callback.



2
3
4
# File 'lib/ops_deploy/waiter.rb', line 2

def callback
  @callback
end

#dataObject

Returns the value of attribute data.



2
3
4
# File 'lib/ops_deploy/waiter.rb', line 2

def data
  @data
end

#end_whenObject

Returns the value of attribute end_when.



2
3
4
# File 'lib/ops_deploy/waiter.rb', line 2

def end_when
  @end_when
end