In Files

Parent

Files

Class/Module Index [+]

Quicksearch

Tarantool::DB

Attributes

closed[R]
closed?[R]
connections[R]
previous_shards_count[R]

Public Class Methods

new(shards, replica_strategy, previous_shards_count, insert_to_previous_shard) click to toggle source
# File lib/tarantool.rb, line 76
def initialize(shards, replica_strategy, previous_shards_count, insert_to_previous_shard)
  @shards = shards
  @replica_strategy = replica_strategy
  @previous_shards_count = previous_shards_count
  @insert_to_previous_shard = insert_to_previous_shard
  @connections = {}
  @closed = false
end

Public Instance Methods

_shard(number) click to toggle source
# File lib/tarantool.rb, line 142
def _shard(number)
  @connections[number] ||= begin
    @shards[number].map do |host, port|
      IProto.get_connection(host, port, self.class::IPROTO_CONNECTION_TYPE)
    end
  end
end
close() click to toggle source
# File lib/tarantool.rb, line 127
def close
  @closed = true
  close_connection
end
close_connection() click to toggle source
# File lib/tarantool.rb, line 150
def close_connection
  @connections.each do |number, replicas|
    replicas.each(&:close)
  end
  @connections.clear
end
insert_with_shards_count() click to toggle source
# File lib/tarantool.rb, line 138
def insert_with_shards_count
  @insert_to_previous_shard && @previous_shards_count || @shards.count
end
method_missing(name, *args) click to toggle source
# File lib/tarantool.rb, line 119
def method_missing(name, *args)
  if query.respond_to?(name)
    query.send(name, *args)
  else
    super
  end
end
primary_interface() click to toggle source
# File lib/tarantool.rb, line 157
def primary_interface
  raise NoMethodError, "#primary_interface should by overriden"
end
query() click to toggle source
# File lib/tarantool.rb, line 115
def query
  @query ||= self.class::Query.new(self)
end
shards_count() click to toggle source
# File lib/tarantool.rb, line 132
def shards_count
  @shards.count
end
space(space_no, fields = [], opts = {}) click to toggle source
# File lib/tarantool.rb, line 96
def space(space_no, fields = [], opts = {})
  case fields
  when Array
    space_array(space_no, fields, opts)
  when Hash
    space_hash(space_no, fields, opts)
  else
    raise "You should specify fields as an array or hash (got #{fields.inspect})"
  end
end
space_array(space_no, field_types = [], opts = {}) click to toggle source

returns regular space, where fields are named by position

tarantool.space_block(0, [:int, :str, :int, :str], keys: [[0], [1,2]])

# File lib/tarantool.rb, line 88
def space_array(space_no, field_types = [], opts = {})
  indexes = opts[:keys] || opts[:indexes]
  shard_fields = opts[:shard_fields]
  shard_proc = opts[:shard_proc]
  self.class::SpaceArray.new(self, space_no, field_types, indexes,
                             shard_fields, shard_proc)
end
space_hash(space_no, fields, opts = {}) click to toggle source
# File lib/tarantool.rb, line 107
def space_hash(space_no, fields, opts = {})
  indexes = opts[:keys] || opts[:indexes]
  shard_fields = opts[:shard_fields]
  shard_proc = opts[:shard_proc]
  self.class::SpaceHash.new(self, space_no, fields, indexes,
                            shard_fields, shard_proc)
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.