Class: RedisClient::Cluster::Transaction

Inherits:
Object
  • Object
show all
Defined in:
lib/redis_client/cluster/transaction.rb

Constant Summary collapse

ConsistencyError =
Class.new(::RedisClient::Error)

Instance Method Summary collapse

Constructor Details

#initialize(router, command_builder) ⇒ Transaction

Returns a new instance of Transaction.



10
11
12
13
14
# File 'lib/redis_client/cluster/transaction.rb', line 10

def initialize(router, command_builder)
  @router = router
  @command_builder = command_builder
  @node_key = nil
end

Instance Method Details

#call(*command, **kwargs, &_) ⇒ Object



16
17
18
19
# File 'lib/redis_client/cluster/transaction.rb', line 16

def call(*command, **kwargs, &_)
  command = @command_builder.generate(command, kwargs)
  ensure_node_key(command)
end

#call_once(*command, **kwargs, &_) ⇒ Object



26
27
28
29
# File 'lib/redis_client/cluster/transaction.rb', line 26

def call_once(*command, **kwargs, &_)
  command = @command_builder.generate(command, kwargs)
  ensure_node_key(command)
end

#call_once_v(command, &_) ⇒ Object



31
32
33
34
# File 'lib/redis_client/cluster/transaction.rb', line 31

def call_once_v(command, &_)
  command = @command_builder.generate(command)
  ensure_node_key(command)
end

#call_v(command, &_) ⇒ Object



21
22
23
24
# File 'lib/redis_client/cluster/transaction.rb', line 21

def call_v(command, &_)
  command = @command_builder.generate(command)
  ensure_node_key(command)
end

#find_node {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:

Raises:

  • (ArgumentError)


36
37
38
39
40
41
# File 'lib/redis_client/cluster/transaction.rb', line 36

def find_node
  yield self
  raise ArgumentError, 'empty transaction' if @node_key.nil?

  @router.find_node(@node_key)
end