Class: AWS::Flow::Core::BeginRescueEnsure

Inherits:
FlowFiber
  • Object
show all
Defined in:
aws-flow-ruby/aws-flow/lib/aws/flow/begin_rescue_ensure.rb

Overview

Enables asynchronous error handling within the AWS Flow Framework for Ruby. Calling #begin/#rescue/#ensure is similar to Ruby's native begin/rescue/end semantics.

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Instance Attribute Details

- (Object) __context__ (readonly)

Returns the value of attribute context



31
32
33
# File 'aws-flow-ruby/aws-flow/lib/aws/flow/begin_rescue_ensure.rb', line 31

def __context__
  @__context__
end

- (Object) backtrace (readonly)

Returns the value of attribute backtrace



31
32
33
# File 'aws-flow-ruby/aws-flow/lib/aws/flow/begin_rescue_ensure.rb', line 31

def backtrace
  @backtrace
end

- (Object) begin_task

Returns the value of attribute begin_task



29
30
31
# File 'aws-flow-ruby/aws-flow/lib/aws/flow/begin_rescue_ensure.rb', line 29

def begin_task
  @begin_task
end

- (Object) cancelled

Returns the value of attribute cancelled



29
30
31
# File 'aws-flow-ruby/aws-flow/lib/aws/flow/begin_rescue_ensure.rb', line 29

def cancelled
  @cancelled
end

- (Object) ensure_task

Returns the value of attribute ensure_task



29
30
31
# File 'aws-flow-ruby/aws-flow/lib/aws/flow/begin_rescue_ensure.rb', line 29

def ensure_task
  @ensure_task
end

- (Object) executor

Returns the value of attribute executor



29
30
31
# File 'aws-flow-ruby/aws-flow/lib/aws/flow/begin_rescue_ensure.rb', line 29

def executor
  @executor
end

- (Object) failure

Returns the value of attribute failure



29
30
31
# File 'aws-flow-ruby/aws-flow/lib/aws/flow/begin_rescue_ensure.rb', line 29

def failure
  @failure
end

- (Object) heirs

Returns the value of attribute heirs



29
30
31
# File 'aws-flow-ruby/aws-flow/lib/aws/flow/begin_rescue_ensure.rb', line 29

def heirs
  @heirs
end

- (Object) nonDaemonHeirsCount

Returns the value of attribute nonDaemonHeirsCount



29
30
31
# File 'aws-flow-ruby/aws-flow/lib/aws/flow/begin_rescue_ensure.rb', line 29

def nonDaemonHeirsCount
  @nonDaemonHeirsCount
end

- (Object) parent

Returns the value of attribute parent



29
30
31
# File 'aws-flow-ruby/aws-flow/lib/aws/flow/begin_rescue_ensure.rb', line 29

def parent
  @parent
end

- (Object) rescue_hash

Returns the value of attribute rescue_hash



29
30
31
# File 'aws-flow-ruby/aws-flow/lib/aws/flow/begin_rescue_ensure.rb', line 29

def rescue_hash
  @rescue_hash
end

- (Object) result

Returns the value of attribute result



29
30
31
# File 'aws-flow-ruby/aws-flow/lib/aws/flow/begin_rescue_ensure.rb', line 29

def result
  @result
end

Instance Method Details

- (Object) begin(block)

Binds the block to a lambda to be called when we get to the begin part of the data flow analysis.

Parameters:

  • block

    The code block to be called when asynchronous begin starts.



268
269
270
271
272
# File 'aws-flow-ruby/aws-flow/lib/aws/flow/begin_rescue_ensure.rb', line 268

def begin(block)
  raise "Duplicated begin" if @begin_task
  # @begin_task = lambda { block.call }
  @begin_task = Task.new(self) { @result.set(block.call) }
end

- (Object) ensure(block)

Binds the block to a lambda to be called when we get to the ensure part of the data flow analysis.

Parameters:

  • block

    The code block to be called when asynchronous ensure starts.



296
297
298
299
# File 'aws-flow-ruby/aws-flow/lib/aws/flow/begin_rescue_ensure.rb', line 296

def ensure(block)
  raise "Duplicated ensure" if @ensure_task
  @ensure_task = Task.new(self) { block.call }
end

- (Object) rescue(error_types, block)

Binds the block to a lambda to be called when we get to the rescue part of the DFA

Parameters:

  • error_types

    The error types.

  • block

    The code block to be called when asynchronous rescue starts.



282
283
284
285
286
287
288
289
# File 'aws-flow-ruby/aws-flow/lib/aws/flow/begin_rescue_ensure.rb', line 282

def rescue(error_types, block)
  error_types = [error_types] unless error_types.is_a? Array
  this_task = lambda { |failure| block.call(failure) }
  if @rescue_hash.key? error_types
    raise "You have already registered #{error_types}"
  end
  @rescue_hash[error_types] = this_task
end

- (Object) schedule



301
302
303
# File 'aws-flow-ruby/aws-flow/lib/aws/flow/begin_rescue_ensure.rb', line 301

def schedule
  @parent << self
end