Class: Tarantool::Client::Stream
- Inherits:
-
Object
- Object
- Tarantool::Client::Stream
- Defined in:
- tarantool-client/lib/tarantool/client/stream.rb
Overview
Operations sent over one IPROTO stream inside an interactive transaction; the server runs a stream's requests in order. Created by Client#transaction.
Constant Summary collapse
- LOST =
'connection lost during the transaction; the server rolled it back'- FINISHED =
'transaction is finished'
Instance Method Summary collapse
-
#initialize(connection:, schema_cache:, id:, request_timeout:, instrumentation: nil) ⇒ Stream
constructor
A new instance of Stream.
- #prepare ⇒ Object
- #transaction(isolation:, timeout:) ⇒ Object
Constructor Details
#initialize(connection:, schema_cache:, id:, request_timeout:, instrumentation: nil) ⇒ Stream
Returns a new instance of Stream.
14 15 16 17 18 19 20 21 22 |
# File 'tarantool-client/lib/tarantool/client/stream.rb', line 14 def initialize(connection:, schema_cache:, id:, request_timeout:, instrumentation: nil) @connection = connection @schema_cache = schema_cache @id = id @request_timeout = request_timeout @instrumentation = instrumentation @state = :idle @pid = Process.pid end |
Instance Method Details
#prepare ⇒ Object
32 33 34 35 |
# File 'tarantool-client/lib/tarantool/client/stream.rb', line 32 def prepare(*) raise TransactionError, 'prepare statements on the client; execute them in the transaction with tx.execute(statement, bindings)' end |
#transaction(isolation:, timeout:) ⇒ Object
24 25 26 27 28 29 30 |
# File 'tarantool-client/lib/tarantool/client/stream.rb', line 24 def transaction(isolation:, timeout:, &) raise TransactionError, TransactionScope::NESTED unless @state == :idle start(isolation, timeout) run(&) end |