Class: FlowNodes::Node

Inherits:
BaseNode show all
Defined in:
lib/flow_nodes/node.rb

Overview

A node with built-in retry logic.

Direct Known Subclasses

AsyncNode, BatchNode

Instance Attribute Summary collapse

Attributes inherited from BaseNode

#params, #successors

Instance Method Summary collapse

Methods inherited from BaseNode

#-, #>>, #exec, #initialize_copy, #nxt, #run, #set_params

Constructor Details

#initialize(max_retries: 1, wait: 0) ⇒ Node

Returns a new instance of Node.



8
9
10
11
12
13
# File 'lib/flow_nodes/node.rb', line 8

def initialize(max_retries: 1, wait: 0)
  super()
  @max_retries = max_retries
  @wait = wait
  @current_retry = 0
end

Instance Attribute Details

#current_retryObject (readonly)

Returns the value of attribute current_retry.



6
7
8
# File 'lib/flow_nodes/node.rb', line 6

def current_retry
  @current_retry
end

#max_retriesObject (readonly)

Returns the value of attribute max_retries.



6
7
8
# File 'lib/flow_nodes/node.rb', line 6

def max_retries
  @max_retries
end

#waitObject (readonly)

Returns the value of attribute wait.



6
7
8
# File 'lib/flow_nodes/node.rb', line 6

def wait
  @wait
end

Instance Method Details

#_run(s) ⇒ Object

Public method to execute the node’s logic with retries. This is the entry point for a flow to run a node.



17
18
19
20
21
22
23
# File 'lib/flow_nodes/node.rb', line 17

def _run(s)
  prepared_params = prep(s)
  actual_params = prepared_params || @params
  execution_result = _exec(actual_params)
  post(s, actual_params, execution_result)
  execution_result
end