lib/grumlin/action.rb in grumlin-0.21.0 vs lib/grumlin/action.rb in grumlin-0.21.1
- old
+ new
@@ -2,18 +2,19 @@
module Grumlin
class Action < Steppable
attr_reader :name, :args, :params, :next_step, :configuration_steps, :previous_step, :shortcut
- def initialize(name, args: [], params: {}, previous_step: nil, pool: nil)
- super()
+ # client is only used when a traversal is a part of transaction
+ def initialize(name, args: [], params: {}, previous_step: nil, pool: Grumlin.default_pool, session_id: nil)
+ super(pool: pool, session_id: session_id)
+
@name = name.to_sym
@args = args # TODO: add recursive validation: only json types or Action
@params = params # TODO: add recursive validation: only json types
@previous_step = previous_step
@shortcut = shortcuts[@name]
- @pool = pool || Grumlin.default_pool
end
def configuration_step?
CONFIGURATION_STEPS.include?(@name)
end
@@ -71,17 +72,21 @@
def to_enum
@to_enum ||= toList.to_enum
end
def toList
- @pool.acquire do |client|
- client.write(bytecode)
- end
+ client_write(bytecode)
end
def iterate
+ client_write(bytecode(no_return: true))
+ end
+
+ private
+
+ def client_write(payload)
@pool.acquire do |client|
- client.write(bytecode(no_return: true))
+ client.write(payload, session_id: @session_id)
end
end
end
end