Module: Tarantool
- Defined in:
- lib/tarantool.rb,
lib/tarantool/util.rb,
lib/tarantool/em_db.rb,
lib/tarantool/query.rb,
lib/tarantool/request.rb,
lib/tarantool/version.rb,
lib/tarantool/block_db.rb,
lib/tarantool/core-ext.rb,
lib/tarantool/fiber_db.rb,
lib/tarantool/response.rb,
lib/tarantool/exceptions.rb,
lib/tarantool/space_hash.rb,
lib/tarantool/base_record.rb,
lib/tarantool/callback_db.rb,
lib/tarantool/serializers.rb,
lib/tarantool/space_array.rb,
lib/tarantool/light_record.rb,
lib/tarantool/record/select.rb,
lib/tarantool/shards_support.rb,
lib/tarantool/serializers/bson.rb,
lib/tarantool/serializers/ber_array.rb,
ext/tarantool/response_c.c
Defined Under Namespace
Modules: ClassAttribute, CommonSpace, CommonSpaceBlockMethods, ParseIProto, Request, Serializers, UnpackTuples, Util Classes: ArgumentError, BadIntegrity, BadReturnCode, BaseRecord, BlockDB, CallbackDB, ConnectionError, DB, Duplicate, DuplicateKey, EMDB, FiberDB, IllegalParams, IntegerFieldOverflow, IsSecondaryPort, LightRecord, LuaError, MemoryIssue, NoMasterError, NonMaster, Query, RecordError, Response, SpaceArray, SpaceHash, StatusCode, StoredProcedureNotDefined, StringTooLong, TarantoolError, TranslateToHash, TryAgain, TupleDoesntExists, TupleExists, TupleIsLocked, TupleReadOnly, UnsupportedCommand, UpdateNewRecord, ValueError, WalIO, WrongField, WrongNumber, WrongVersion
Constant Summary collapse
- DEFAULT_PORT =
autoload :Record, ‘tarantool/record’ autoload :LightRecord, ‘tarantool/light_record’
33013
- VERSION =
"0.5.8"
- RECORD_VERSION =
"0.4.3"
- CODE_TO_EXCEPTION =
{ 0x0401 => TupleReadOnly, 0x0601 => TupleIsLocked, 0x0701 => MemoryIssue, 0x0102 => NonMaster, 0x0202 => IllegalParams, 0x0302 => IsSecondaryPort, 0x0802 => BadIntegrity, 0x0a02 => UnsupportedCommand, 0x1e02 => WrongField, 0x1f02 => WrongNumber, 0x2002 => Duplicate, 0x2602 => WrongVersion, 0x2702 => WalIO, 0x3102 => TupleDoesntExists, 0x3202 => StoredProcedureNotDefined, 0x3302 => LuaError, 0x3702 => TupleExists, 0x3802 => DuplicateKey, }
Class Method Summary collapse
Class Method Details
.new(conf) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/tarantool.rb', line 17 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 %w{round_robin master_first}.include?(replica_strategy) replica_strategy = replica_strategy.to_sym end unless [:round_robin, :master_first, :prefer_slave].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 |