Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

record: fix check for connection type

  • Loading branch information...
commit 026c472132e4bf45c927e7fd1904004926ca99a1 1 parent cbb8a61
@funny-falcon funny-falcon authored
View
4 lib/tarantool.rb
@@ -142,5 +142,9 @@ def close_connection
end
@connections.clear
end
+
+ def primary_interface
+ raise NoMethodError, "#primary_interface should by overriden"
+ end
end
end
View
2  lib/tarantool/base_record.rb
@@ -40,7 +40,7 @@ def tarantool(v=nil)
def tarantool=(v)
reset_space!
- unless ::Tarantool::BlockDB === v || ::Tarantool::FiberDB === v
+ unless ::Tarantool::DB === v && v.primary_interface == :synchronous
raise ArgumentError, "you may assing to record's tarantool only instances of Tarantool::BlockDB or Tarantool::FiberDB"
end
self._tarantool= v
View
4 lib/tarantool/block_db.rb
@@ -83,6 +83,10 @@ def _send_to_several_shards(shard_numbers, read_write, request_type, body, respo
results
end
+ def primary_interface
+ :synchronous
+ end
+
module CommonSpaceBlockingMethods
def _block_cb
@_block_cb ||= method(:_raise_or_return)
View
4 lib/tarantool/callback_db.rb
@@ -2,6 +2,10 @@
module Tarantool
class CallbackDB < EMDB
+ def primary_interface
+ :callback
+ end
+
class SpaceArray < ::Tarantool::SpaceArray
alias by_pk by_pk_blk
alias all_by_key all_by_key_blk
View
4 lib/tarantool/fiber_db.rb
@@ -3,6 +3,10 @@
module Tarantool
class FiberDB < EMDB
+ def primary_interface
+ :synchronous
+ end
+
module CommonSpaceFiberMethods
def all_by_pks(pks, opts={})
all_by_pks_cb(pks, ::Fiber.current, opts)
Please sign in to comment.
Something went wrong with that request. Please try again.