Methods

Files

Class/Module Index [+]

Quicksearch

Tarantool

Constants

CODE_TO_EXCEPTION
DEFAULT_PORT

autoload :Record, 'tarantool/record' autoload :LightRecord, 'tarantool/light_record'

RECORD_VERSION
VERSION

Public Class Methods

new(conf) click to toggle source
# File lib/tarantool.rb, line 18
def new(conf)
  if conf[:host]
    shards = [ [ _fix_connection(conf) ] ]
  else
    shards = conf[:servers]
    unless shards.is_a? Array
      shards = [ shards ]
    end
    unless shards.first.is_a? Array
      shards = [ shards ]
    end
    shards = shards.map{|shard| shard.map{|server| _fix_connection(server)}}
  end

  replica_strategy = conf[:replica_strategy] || :round_robin
  if %{round_robin master_first}.include?(replica_strategy)
    replica_strategy = replica_strategy.to_sym
  end
  unless [:round_robin, :master_first].include?(replica_strategy)
    raise ArgumentError, "Shard strategy could be :round_robin or :master_first, got #{replica_strategy.inspect}"
  end

  previous_shards_count = conf[:previous_shards_count]
  insert_to_previous_shard = conf[:insert_to_previous_shard]

  case conf[:type] || :block
  when :em, :em_fiber
    require 'tarantool/fiber_db'
    FiberDB.new(shards, replica_strategy, previous_shards_count, insert_to_previous_shard)
  when :em_cb, :em_callback
    require 'tarantool/callback_db'
    CallbackDB.new(shards, replica_strategy, previous_shards_count, insert_to_previous_shard)
  when :block
    require 'tarantool/block_db'
    BlockDB.new(shards, replica_strategy, previous_shards_count, insert_to_previous_shard)
  else
    raise "Unknown Tarantool connection type #{conf[:type]}"
  end
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.