tarantool-client 0.3.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +2 -0
- data/lib/tarantool/client/configuration.rb +9 -3
- data/lib/tarantool/client/pool/member_role.rb +2 -2
- data/lib/tarantool/client/protocol/greeting.rb +4 -2
- data/lib/tarantool/client/uuid.rb +4 -2
- data/lib/tarantool/client/version.rb +1 -1
- data/sig/tarantool/client/pool.rbs +41 -0
- data/sig/tarantool/client/stream.rbs +26 -0
- data/sig/tarantool/client/values.rbs +179 -0
- data/sig/tarantool/client.rbs +73 -0
- data/sig/tarantool/errors.rbs +47 -0
- metadata +15 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 046c9d293325df27a2971c6c6257cd6691e3e6c2cb565ea41eb9cb1aa5a2ccf3
|
|
4
|
+
data.tar.gz: 2dc134d5da8d6f5a99fd8b73f28340ae022ae9243c62d750287e35e5d088d159
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8cb3cae463060a270127eea6427eacef15edd25ec159d6d377f97af2692d9fc7fade4fef6b871943cfe78387d740621c5061b583bfe2ae755ca06f8e8a7f282c
|
|
7
|
+
data.tar.gz: c456c5a8fa8a0c8de99804f29fd0c36831a35f692391c3cda7c582f1901fc7ee46cbf7fc709fed866bcba121b6fa4b5de6bbc4da6a5ea8ebe3e380f99a133a18
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.3.1 (2026-10-18)
|
|
4
|
+
|
|
5
|
+
- Allows `bigdecimal` 4.x, the version Ruby 4 ships with.
|
|
6
|
+
|
|
3
7
|
## 0.3.0 (2026-10-17)
|
|
4
8
|
|
|
5
9
|
- `select(fetch_position: true)` returns a `Page` with the server-side position of the last tuple; `after:` takes that position (String) as well as a tuple.
|
data/README.md
CHANGED
|
@@ -309,6 +309,8 @@ Don't create multikey indexes on these containers: with `memtx_use_mvcc_engine =
|
|
|
309
309
|
`Watcher` (returned by `watch`), `SqlResult`, `PreparedStatement`, `SpaceInfo`, `IndexInfo`, `Row`, `Page`, `Configuration`
|
|
310
310
|
(returned by `client.config`), `Tarantool::Client::UUID`, `Interval`, `BoxError`, and the error classes above.
|
|
311
311
|
|
|
312
|
+
RBS signatures for this API ship with the gem in `sig/`.
|
|
313
|
+
|
|
312
314
|
Everything else, including anything tagged `@api private` in its source comment, is an implementation detail
|
|
313
315
|
and may change in any release.
|
|
314
316
|
|
|
@@ -24,15 +24,15 @@ module Tarantool
|
|
|
24
24
|
|
|
25
25
|
def self.parse_uri(uri)
|
|
26
26
|
return {} if uri.nil?
|
|
27
|
-
return parse_unix_uri(uri) if uri.match?(
|
|
27
|
+
return parse_unix_uri(uri) if uri.match?(Configuration::UNIX_URI)
|
|
28
28
|
|
|
29
29
|
parse_tcp_uri(uri)
|
|
30
30
|
end
|
|
31
31
|
|
|
32
32
|
def self.parse_unix_uri(uri)
|
|
33
|
-
match =
|
|
33
|
+
match = Configuration::UNIX_PATH.match(uri)
|
|
34
34
|
path = match && match[1]
|
|
35
|
-
raise ArgumentError, 'invalid Tarantool URI' if path.nil? || path.match?(
|
|
35
|
+
raise ArgumentError, 'invalid Tarantool URI' if path.nil? || path.match?(Configuration::EMPTY_PATH)
|
|
36
36
|
|
|
37
37
|
{ path: path }
|
|
38
38
|
end
|
|
@@ -84,5 +84,11 @@ module Tarantool
|
|
|
84
84
|
klass.name ? "#<#{klass.name}>" : klass.inspect
|
|
85
85
|
end
|
|
86
86
|
end
|
|
87
|
+
|
|
88
|
+
class Configuration
|
|
89
|
+
UNIX_URI = %r{\Aunix/?:}
|
|
90
|
+
UNIX_PATH = %r{\Aunix/?:(?://(?=/))?(.+)\z}
|
|
91
|
+
EMPTY_PATH = %r{\A/*\z}
|
|
92
|
+
end
|
|
87
93
|
end
|
|
88
94
|
end
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
module Tarantool
|
|
4
4
|
class Client
|
|
5
5
|
class Pool
|
|
6
|
-
# The role a member's instance reports through box.status. Includers set @lock, @changed, @read_only
|
|
7
|
-
# @instrumentation.
|
|
6
|
+
# The role a member's instance reports through box.status. Includers set @lock, @changed, @read_only
|
|
7
|
+
# and @instrumentation.
|
|
8
8
|
# @api private
|
|
9
9
|
module MemberRole
|
|
10
10
|
private
|
|
@@ -6,8 +6,6 @@ module Tarantool
|
|
|
6
6
|
# Greeting sent by the server on connect: a 64-byte banner and a 64-byte base64 salt line.
|
|
7
7
|
# @api private
|
|
8
8
|
Greeting = Data.define(:version, :salt) do
|
|
9
|
-
self::BANNER_VERSION = /\ATarantool (\S+)/
|
|
10
|
-
|
|
11
9
|
def self.parse(bytes)
|
|
12
10
|
banner = bytes.byteslice(0, 64)
|
|
13
11
|
version = banner[Greeting::BANNER_VERSION, 1]
|
|
@@ -16,6 +14,10 @@ module Tarantool
|
|
|
16
14
|
new(version:, salt: bytes.byteslice(64, 64).strip.unpack1('m'))
|
|
17
15
|
end
|
|
18
16
|
end
|
|
17
|
+
|
|
18
|
+
class Greeting
|
|
19
|
+
BANNER_VERSION = /\ATarantool (\S+)/
|
|
20
|
+
end
|
|
19
21
|
end
|
|
20
22
|
end
|
|
21
23
|
end
|
|
@@ -4,8 +4,6 @@ module Tarantool
|
|
|
4
4
|
class Client
|
|
5
5
|
# A Tarantool uuid value; only instances of this type are sent as MP_EXT uuid, never plain strings.
|
|
6
6
|
UUID = Data.define(:value) do
|
|
7
|
-
self::FORMAT = /\A\h{8}-\h{4}-\h{4}-\h{4}-\h{12}\z/
|
|
8
|
-
|
|
9
7
|
def initialize(value:)
|
|
10
8
|
raise ArgumentError, "invalid UUID: #{value.inspect}" unless value.is_a?(String) && value.match?(UUID::FORMAT)
|
|
11
9
|
|
|
@@ -16,5 +14,9 @@ module Tarantool
|
|
|
16
14
|
value
|
|
17
15
|
end
|
|
18
16
|
end
|
|
17
|
+
|
|
18
|
+
class UUID
|
|
19
|
+
FORMAT = /\A\h{8}-\h{4}-\h{4}-\h{4}-\h{12}\z/
|
|
20
|
+
end
|
|
19
21
|
end
|
|
20
22
|
end
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
module Tarantool
|
|
2
|
+
class Client
|
|
3
|
+
# Clients for the instances of one replica set, routed by the role each reports through box.status.
|
|
4
|
+
class Pool
|
|
5
|
+
type mode = :rw | :ro | :prefer_ro | :prefer_rw | :any
|
|
6
|
+
|
|
7
|
+
MODES: Array[mode]
|
|
8
|
+
|
|
9
|
+
def initialize: (Array[String] addresses, ?host: String, ?port: Integer, ?path: String?, ?user: String?,
|
|
10
|
+
?password: String?, ?connect_timeout: Numeric?, ?request_timeout: Numeric?, ?reconnect: bool,
|
|
11
|
+
?reconnect_attempts: Numeric, ?reconnect_delay: Numeric, ?reconnect_max_delay: Numeric,
|
|
12
|
+
?max_frame_size: Integer, ?instrumenter: _Instrumenter?, ?logger: _Logger?) -> void
|
|
13
|
+
|
|
14
|
+
def ping: (?mode: mode, ?timeout: Numeric?) -> true
|
|
15
|
+
def space_info: (space_ref space, ?mode: mode, ?timeout: Numeric?) -> SpaceInfo
|
|
16
|
+
def select: (space_ref space, ?key key, ?mode: mode, ?index: index_ref, ?limit: Integer, ?offset: Integer,
|
|
17
|
+
?iterator: iterator, ?after: cursor?, ?fetch_position: bool, ?as: shape,
|
|
18
|
+
?timeout: Numeric?) -> (Array[row] | Page)
|
|
19
|
+
def insert: (space_ref space, tuple_input tuple, ?mode: mode, ?as: shape, ?timeout: Numeric?) -> row
|
|
20
|
+
def replace: (space_ref space, tuple_input tuple, ?mode: mode, ?as: shape, ?timeout: Numeric?) -> row
|
|
21
|
+
def update: (space_ref space, key key, Array[operation] operations, ?mode: mode, ?index: index_ref, ?as: shape,
|
|
22
|
+
?timeout: Numeric?) -> row?
|
|
23
|
+
def upsert: (space_ref space, tuple_input tuple, Array[operation] operations, ?mode: mode,
|
|
24
|
+
?timeout: Numeric?) -> nil
|
|
25
|
+
def delete: (space_ref space, key key, ?mode: mode, ?index: index_ref, ?as: shape, ?timeout: Numeric?) -> row?
|
|
26
|
+
def delete_by: (space_ref space, key key, index: index_ref, ?mode: mode, ?iterator: iterator,
|
|
27
|
+
?batch_size: Integer, ?timeout: Numeric?) -> Integer
|
|
28
|
+
def call: (String function_name, ?Array[untyped] arguments, ?mode: mode, ?timeout: Numeric?,
|
|
29
|
+
?on_push: (^(untyped message) -> void)?) -> Array[untyped]
|
|
30
|
+
def eval: (String expression, ?Array[untyped] arguments, ?mode: mode, ?timeout: Numeric?) -> Array[untyped]
|
|
31
|
+
def execute: (String | Integer | PreparedStatement sql, ?Array[untyped] bindings, ?mode: mode,
|
|
32
|
+
?timeout: Numeric?) -> SqlResult
|
|
33
|
+
def prepare: (String sql, ?mode: mode, ?timeout: Numeric?) -> PreparedStatement
|
|
34
|
+
|
|
35
|
+
# Always on a writable instance.
|
|
36
|
+
def transaction: [T] (?isolation: isolation, ?timeout: Numeric?) { (Stream) -> T } -> T
|
|
37
|
+
def close: () -> void
|
|
38
|
+
def inspect: () -> String
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
module Tarantool
|
|
2
|
+
class Client
|
|
3
|
+
# The operations of one interactive transaction, yielded by Client#transaction and Pool#transaction.
|
|
4
|
+
class Stream
|
|
5
|
+
def ping: (?timeout: Numeric?) -> true
|
|
6
|
+
def space_info: (space_ref space, ?timeout: Numeric?) -> SpaceInfo
|
|
7
|
+
def select: (space_ref space, ?key key, ?index: index_ref, ?limit: Integer, ?offset: Integer,
|
|
8
|
+
?iterator: iterator, ?after: cursor?, ?fetch_position: bool, ?as: shape,
|
|
9
|
+
?timeout: Numeric?) -> (Array[row] | Page)
|
|
10
|
+
def insert: (space_ref space, tuple_input tuple, ?as: shape, ?timeout: Numeric?) -> row
|
|
11
|
+
def replace: (space_ref space, tuple_input tuple, ?as: shape, ?timeout: Numeric?) -> row
|
|
12
|
+
def update: (space_ref space, key key, Array[operation] operations, ?index: index_ref, ?as: shape,
|
|
13
|
+
?timeout: Numeric?) -> row?
|
|
14
|
+
def upsert: (space_ref space, tuple_input tuple, Array[operation] operations, ?timeout: Numeric?) -> nil
|
|
15
|
+
def delete: (space_ref space, key key, ?index: index_ref, ?as: shape, ?timeout: Numeric?) -> row?
|
|
16
|
+
def delete_by: (space_ref space, key key, index: index_ref, ?iterator: iterator, ?batch_size: Integer,
|
|
17
|
+
?timeout: Numeric?) -> Integer
|
|
18
|
+
def call: (String function_name, ?Array[untyped] arguments, ?timeout: Numeric?,
|
|
19
|
+
?on_push: (^(untyped message) -> void)?) -> Array[untyped]
|
|
20
|
+
def eval: (String expression, ?Array[untyped] arguments, ?timeout: Numeric?) -> Array[untyped]
|
|
21
|
+
def execute: (String | Integer | PreparedStatement sql, ?Array[untyped] bindings, ?timeout: Numeric?) -> SqlResult
|
|
22
|
+
# Raises TransactionError: prepare on the client, execute the statement here.
|
|
23
|
+
def prepare: (*untyped) -> bot
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
module Tarantool
|
|
2
|
+
class Client
|
|
3
|
+
# Subscription returned by Client#watch.
|
|
4
|
+
class Watcher
|
|
5
|
+
attr_reader key: String
|
|
6
|
+
|
|
7
|
+
def unwatch: () -> nil
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
# Server-side prepared SQL statement, bound to the session that prepared it.
|
|
11
|
+
class PreparedStatement
|
|
12
|
+
attr_reader id: Integer
|
|
13
|
+
|
|
14
|
+
def execute: (?Array[untyped] bindings, ?timeout: Numeric?) -> SqlResult
|
|
15
|
+
def close: (?timeout: Numeric?) -> nil
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
# Rows and column names of an SQL query, or the counters of a data-changing statement.
|
|
19
|
+
class SqlResult < Data
|
|
20
|
+
attr_reader rows: Array[Array[untyped]]
|
|
21
|
+
attr_reader columns: Array[String]
|
|
22
|
+
attr_reader row_count: Integer?
|
|
23
|
+
attr_reader autoincrement_ids: Array[Integer]
|
|
24
|
+
|
|
25
|
+
def self.new: (rows: Array[Array[untyped]], columns: Array[String], row_count: Integer?,
|
|
26
|
+
autoincrement_ids: Array[Integer]) -> SqlResult
|
|
27
|
+
def with: (?rows: Array[Array[untyped]], ?columns: Array[String], ?row_count: Integer?,
|
|
28
|
+
?autoincrement_ids: Array[Integer]) -> SqlResult
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
# A tuple as the server returned it, with its fields by name. Returned for `as: :row`.
|
|
32
|
+
class Row < Data
|
|
33
|
+
attr_reader tuple: tuple
|
|
34
|
+
attr_reader attributes: row_hash
|
|
35
|
+
|
|
36
|
+
def self.new: (tuple: tuple, attributes: row_hash) -> Row
|
|
37
|
+
def with: (?tuple: tuple, ?attributes: row_hash) -> Row
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# One page of a select asked with `fetch_position: true`.
|
|
41
|
+
class Page < Data
|
|
42
|
+
include Enumerable[row]
|
|
43
|
+
|
|
44
|
+
attr_reader tuples: Array[row]
|
|
45
|
+
# Opaque, tied to the index and iterator that produced it; nil when the page is empty.
|
|
46
|
+
attr_reader position: String?
|
|
47
|
+
|
|
48
|
+
def self.new: (tuples: Array[row], position: String?) -> Page
|
|
49
|
+
def with: (?tuples: Array[row], ?position: String?) -> Page
|
|
50
|
+
def each: () { (row) -> void } -> Array[row]
|
|
51
|
+
| () -> Enumerator[row, Array[row]]
|
|
52
|
+
def empty?: () -> bool
|
|
53
|
+
def size: () -> Integer
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
# Format and indexes of a space from the loaded schema; `indexes` maps names to IndexInfo in id order.
|
|
57
|
+
class SpaceInfo < Data
|
|
58
|
+
attr_reader id: Integer
|
|
59
|
+
attr_reader name: String
|
|
60
|
+
attr_reader fields: Array[SpaceInfo::Field]
|
|
61
|
+
attr_reader indexes: Hash[String, IndexInfo]
|
|
62
|
+
|
|
63
|
+
def self.new: (id: Integer, name: String, fields: Array[SpaceInfo::Field], indexes: Hash[String, IndexInfo]) -> SpaceInfo
|
|
64
|
+
def with: (?id: Integer, ?name: String, ?fields: Array[SpaceInfo::Field], ?indexes: Hash[String, IndexInfo]) -> SpaceInfo
|
|
65
|
+
def primary_index: () -> IndexInfo?
|
|
66
|
+
def to_hash: (tuple tuple) -> row_hash
|
|
67
|
+
# An unknown name raises UnknownFieldError; missing fields go out as nil.
|
|
68
|
+
def to_tuple: (Hash[Symbol | String | Integer, untyped] hash) -> tuple
|
|
69
|
+
|
|
70
|
+
class Field < Data
|
|
71
|
+
attr_reader name: String
|
|
72
|
+
attr_reader type: String
|
|
73
|
+
attr_reader is_nullable: bool
|
|
74
|
+
|
|
75
|
+
def self.new: (name: String, type: String, is_nullable: bool) -> Field
|
|
76
|
+
def with: (?name: String, ?type: String, ?is_nullable: bool) -> Field
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
# One index of a space.
|
|
81
|
+
class IndexInfo < Data
|
|
82
|
+
attr_reader id: Integer
|
|
83
|
+
attr_reader name: String
|
|
84
|
+
attr_reader type: String
|
|
85
|
+
attr_reader unique: bool
|
|
86
|
+
attr_reader parts: Array[IndexInfo::Part]
|
|
87
|
+
|
|
88
|
+
def self.new: (id: Integer, name: String, type: String, unique: bool, parts: Array[IndexInfo::Part]) -> IndexInfo
|
|
89
|
+
def with: (?id: Integer, ?name: String, ?type: String, ?unique: bool, ?parts: Array[IndexInfo::Part]) -> IndexInfo
|
|
90
|
+
|
|
91
|
+
# `fieldno` is 0-based; `name` is nil for a field beyond the space format.
|
|
92
|
+
class Part < Data
|
|
93
|
+
attr_reader fieldno: Integer
|
|
94
|
+
attr_reader name: String?
|
|
95
|
+
attr_reader type: String
|
|
96
|
+
attr_reader is_nullable: bool
|
|
97
|
+
attr_reader path: String?
|
|
98
|
+
|
|
99
|
+
def self.new: (fieldno: Integer, name: String?, type: String, is_nullable: bool, path: String?) -> Part
|
|
100
|
+
def with: (?fieldno: Integer, ?name: String?, ?type: String, ?is_nullable: bool, ?path: String?) -> Part
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
# A Tarantool uuid; only instances of this type are sent as MP_EXT uuid.
|
|
105
|
+
class UUID < Data
|
|
106
|
+
FORMAT: Regexp
|
|
107
|
+
|
|
108
|
+
attr_reader value: String
|
|
109
|
+
|
|
110
|
+
def self.new: (String value) -> UUID
|
|
111
|
+
| (value: String) -> UUID
|
|
112
|
+
def with: (?value: String) -> UUID
|
|
113
|
+
def to_s: () -> String
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
# A Tarantool datetime.interval; adjust is :none, :excess or :last.
|
|
117
|
+
class Interval < Data
|
|
118
|
+
type adjust = :none | :excess | :last
|
|
119
|
+
|
|
120
|
+
attr_reader year: Integer
|
|
121
|
+
attr_reader month: Integer
|
|
122
|
+
attr_reader week: Integer
|
|
123
|
+
attr_reader day: Integer
|
|
124
|
+
attr_reader hour: Integer
|
|
125
|
+
attr_reader min: Integer
|
|
126
|
+
attr_reader sec: Integer
|
|
127
|
+
attr_reader nsec: Integer
|
|
128
|
+
attr_reader adjust: adjust
|
|
129
|
+
|
|
130
|
+
def self.new: (?year: Integer, ?month: Integer, ?week: Integer, ?day: Integer, ?hour: Integer, ?min: Integer,
|
|
131
|
+
?sec: Integer, ?nsec: Integer, ?adjust: adjust) -> Interval
|
|
132
|
+
def with: (?year: Integer, ?month: Integer, ?week: Integer, ?day: Integer, ?hour: Integer, ?min: Integer,
|
|
133
|
+
?sec: Integer, ?nsec: Integer, ?adjust: adjust) -> Interval
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
# A box.error object returned as data (MP_ERROR), with its cause chain.
|
|
137
|
+
class BoxError < Data
|
|
138
|
+
attr_reader type: String?
|
|
139
|
+
attr_reader message: String?
|
|
140
|
+
attr_reader code: Integer?
|
|
141
|
+
attr_reader file: String?
|
|
142
|
+
attr_reader line: Integer?
|
|
143
|
+
attr_reader errno: Integer?
|
|
144
|
+
attr_reader fields: Hash[String, untyped]?
|
|
145
|
+
attr_reader cause: BoxError?
|
|
146
|
+
|
|
147
|
+
def self.new: (type: String?, message: String?, code: Integer?, file: String?, line: Integer?, errno: Integer?,
|
|
148
|
+
fields: Hash[String, untyped]?, cause: BoxError?) -> BoxError
|
|
149
|
+
def with: (?type: String?, ?message: String?, ?code: Integer?, ?file: String?, ?line: Integer?, ?errno: Integer?,
|
|
150
|
+
?fields: Hash[String, untyped]?, ?cause: BoxError?) -> BoxError
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
# Immutable connection settings; `inspect` and `to_s` hide the password, `to_h` keeps it.
|
|
154
|
+
class Configuration < Data
|
|
155
|
+
attr_reader host: String
|
|
156
|
+
attr_reader port: Integer
|
|
157
|
+
attr_reader path: String?
|
|
158
|
+
attr_reader user: String?
|
|
159
|
+
attr_reader password: String?
|
|
160
|
+
attr_reader connect_timeout: Numeric?
|
|
161
|
+
attr_reader request_timeout: Numeric?
|
|
162
|
+
attr_reader reconnect: bool
|
|
163
|
+
attr_reader reconnect_attempts: Numeric
|
|
164
|
+
attr_reader reconnect_delay: Numeric
|
|
165
|
+
attr_reader reconnect_max_delay: Numeric
|
|
166
|
+
attr_reader max_frame_size: Integer
|
|
167
|
+
attr_reader instrumenter: _Instrumenter?
|
|
168
|
+
attr_reader logger: _Logger?
|
|
169
|
+
|
|
170
|
+
def self.build: (?String? uri, ?host: String, ?port: Integer, ?path: String?, ?user: String?, ?password: String?,
|
|
171
|
+
?connect_timeout: Numeric?, ?request_timeout: Numeric?, ?reconnect: bool,
|
|
172
|
+
?reconnect_attempts: Numeric, ?reconnect_delay: Numeric, ?reconnect_max_delay: Numeric,
|
|
173
|
+
?max_frame_size: Integer, ?instrumenter: _Instrumenter?, ?logger: _Logger?) -> Configuration
|
|
174
|
+
def address: () -> String
|
|
175
|
+
def inspect: () -> String
|
|
176
|
+
def to_s: () -> String
|
|
177
|
+
end
|
|
178
|
+
end
|
|
179
|
+
end
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
module Tarantool
|
|
2
|
+
# Connection to one Tarantool instance.
|
|
3
|
+
class Client
|
|
4
|
+
VERSION: String
|
|
5
|
+
|
|
6
|
+
# A space or index, by name or numeric id.
|
|
7
|
+
type space_ref = String | Symbol | Integer
|
|
8
|
+
type index_ref = String | Symbol | Integer
|
|
9
|
+
# A tuple as sent and received: an Array of msgpack values.
|
|
10
|
+
type tuple = Array[untyped]
|
|
11
|
+
# A tuple keyed by field name; fields beyond the format are keyed by their 0-based position.
|
|
12
|
+
type row_hash = Hash[Symbol | Integer, untyped]
|
|
13
|
+
# Tuples go out as Arrays or as Hashes keyed by field name (Symbol or String).
|
|
14
|
+
type tuple_input = tuple | Hash[Symbol | String, untyped]
|
|
15
|
+
# One msgpack value of a key part.
|
|
16
|
+
type scalar = Integer | Float | String | bool | nil | BigDecimal | Time | UUID | Interval
|
|
17
|
+
# An index key: the parts as an Array, or one scalar for a single-part key.
|
|
18
|
+
type key = Array[untyped] | scalar
|
|
19
|
+
type iterator = :eq | :req | :all | :lt | :le | :ge | :gt | :bits_all_set | :bits_any_set | :bits_all_not_set |
|
|
20
|
+
:overlaps | :neighbor | :np | :pp
|
|
21
|
+
type shape = :tuple | :hash | :row
|
|
22
|
+
# One update operation, e.g. ['=', 'name', value] or ['+', 2, 1]; splice operations have five elements.
|
|
23
|
+
type operation = Array[untyped]
|
|
24
|
+
# What select returns for one tuple, by `as:`.
|
|
25
|
+
type row = tuple | row_hash | Row
|
|
26
|
+
type isolation = :default | :read_committed | :read_confirmed | :best_effort | :linearizable
|
|
27
|
+
# A position from Page#position, or the last tuple of the previous page.
|
|
28
|
+
type cursor = String | tuple
|
|
29
|
+
|
|
30
|
+
interface _Instrumenter
|
|
31
|
+
def instrument: (String name, Hash[Symbol, untyped] payload) { () -> untyped } -> untyped
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
interface _Logger
|
|
35
|
+
def debug: (?untyped message) ?{ () -> untyped } -> untyped
|
|
36
|
+
def info: (?untyped message) ?{ () -> untyped } -> untyped
|
|
37
|
+
def warn: (?untyped message) ?{ () -> untyped } -> untyped
|
|
38
|
+
def error: (?untyped message) ?{ () -> untyped } -> untyped
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
attr_reader config: Configuration
|
|
42
|
+
|
|
43
|
+
def initialize: (?String? uri, ?host: String, ?port: Integer, ?path: String?, ?user: String?, ?password: String?,
|
|
44
|
+
?connect_timeout: Numeric?, ?request_timeout: Numeric?, ?reconnect: bool,
|
|
45
|
+
?reconnect_attempts: Numeric, ?reconnect_delay: Numeric, ?reconnect_max_delay: Numeric,
|
|
46
|
+
?max_frame_size: Integer, ?instrumenter: _Instrumenter?, ?logger: _Logger?) -> void
|
|
47
|
+
|
|
48
|
+
def ping: (?timeout: Numeric?) -> true
|
|
49
|
+
def space_info: (space_ref space, ?timeout: Numeric?) -> SpaceInfo
|
|
50
|
+
def select: (space_ref space, ?key key, ?index: index_ref, ?limit: Integer, ?offset: Integer, ?iterator: iterator,
|
|
51
|
+
?after: cursor?, ?fetch_position: bool, ?as: shape, ?timeout: Numeric?) -> (Array[row] | Page)
|
|
52
|
+
def insert: (space_ref space, tuple_input tuple, ?as: shape, ?timeout: Numeric?) -> row
|
|
53
|
+
def replace: (space_ref space, tuple_input tuple, ?as: shape, ?timeout: Numeric?) -> row
|
|
54
|
+
def update: (space_ref space, key key, Array[operation] operations, ?index: index_ref, ?as: shape,
|
|
55
|
+
?timeout: Numeric?) -> row?
|
|
56
|
+
def upsert: (space_ref space, tuple_input tuple, Array[operation] operations, ?timeout: Numeric?) -> nil
|
|
57
|
+
def delete: (space_ref space, key key, ?index: index_ref, ?as: shape, ?timeout: Numeric?) -> row?
|
|
58
|
+
def delete_by: (space_ref space, key key, index: index_ref, ?iterator: iterator, ?batch_size: Integer,
|
|
59
|
+
?timeout: Numeric?) -> Integer
|
|
60
|
+
def call: (String function_name, ?Array[untyped] arguments, ?timeout: Numeric?,
|
|
61
|
+
?on_push: (^(untyped message) -> void)?) -> Array[untyped]
|
|
62
|
+
def eval: (String expression, ?Array[untyped] arguments, ?timeout: Numeric?) -> Array[untyped]
|
|
63
|
+
def execute: (String | Integer | PreparedStatement sql, ?Array[untyped] bindings, ?timeout: Numeric?) -> SqlResult
|
|
64
|
+
def prepare: (String sql, ?timeout: Numeric?) -> PreparedStatement
|
|
65
|
+
|
|
66
|
+
def server_version: () -> String
|
|
67
|
+
def connected?: () -> bool
|
|
68
|
+
def transaction: [T] (?isolation: isolation, ?timeout: Numeric?) { (Stream) -> T } -> T
|
|
69
|
+
def watch: (String key) { (String key, untyped value) -> void } -> Watcher
|
|
70
|
+
def close: () -> void
|
|
71
|
+
def inspect: () -> String
|
|
72
|
+
end
|
|
73
|
+
end
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
module Tarantool
|
|
2
|
+
# Base class for every error raised by the tarantool-* gems.
|
|
3
|
+
class Error < StandardError
|
|
4
|
+
# Rows delete_by confirmed deleted before it failed; nil for any other operation.
|
|
5
|
+
attr_accessor deleted: Integer?
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
class ConnectionError < Error
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
class ClientClosedError < ConnectionError
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
class TimeoutError < Error
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
class AuthenticationError < Error
|
|
18
|
+
attr_reader code: Integer?
|
|
19
|
+
|
|
20
|
+
def initialize: (?String? message, ?code: Integer?) -> void
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
class ProtocolError < Error
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
class SchemaError < Error
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
class UnknownFieldError < ArgumentError
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
class TransactionError < Error
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
class NoAvailableInstanceError < Error
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
class ServerError < Error
|
|
39
|
+
attr_reader code: Integer
|
|
40
|
+
# The box.error stack as sent: one Hash per error (keys :type, :file, :line, :message, :errno, :code,
|
|
41
|
+
# :fields); the constructor takes whatever Array it is given.
|
|
42
|
+
attr_reader error_stack: Array[untyped]
|
|
43
|
+
attr_reader schema_version: Integer?
|
|
44
|
+
|
|
45
|
+
def initialize: (String? message, code: Integer, ?error_stack: Array[untyped], ?schema_version: Integer?) -> void
|
|
46
|
+
end
|
|
47
|
+
end
|
metadata
CHANGED
|
@@ -1,29 +1,35 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: tarantool-client
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.3.
|
|
4
|
+
version: 0.3.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Starlexxx
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-10-
|
|
11
|
+
date: 2026-10-18 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bigdecimal
|
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
|
16
16
|
requirements:
|
|
17
|
-
- - "
|
|
17
|
+
- - ">="
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
19
|
version: '3.1'
|
|
20
|
+
- - "<"
|
|
21
|
+
- !ruby/object:Gem::Version
|
|
22
|
+
version: '5'
|
|
20
23
|
type: :runtime
|
|
21
24
|
prerelease: false
|
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
26
|
requirements:
|
|
24
|
-
- - "
|
|
27
|
+
- - ">="
|
|
25
28
|
- !ruby/object:Gem::Version
|
|
26
29
|
version: '3.1'
|
|
30
|
+
- - "<"
|
|
31
|
+
- !ruby/object:Gem::Version
|
|
32
|
+
version: '5'
|
|
27
33
|
- !ruby/object:Gem::Dependency
|
|
28
34
|
name: msgpack
|
|
29
35
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -132,6 +138,11 @@ files:
|
|
|
132
138
|
- lib/tarantool/client/watcher.rb
|
|
133
139
|
- lib/tarantool/client/watchers.rb
|
|
134
140
|
- lib/tarantool/client/watchers/dispatcher.rb
|
|
141
|
+
- sig/tarantool/client.rbs
|
|
142
|
+
- sig/tarantool/client/pool.rbs
|
|
143
|
+
- sig/tarantool/client/stream.rbs
|
|
144
|
+
- sig/tarantool/client/values.rbs
|
|
145
|
+
- sig/tarantool/errors.rbs
|
|
135
146
|
homepage: https://github.com/Starlexxx/tarantool-ruby
|
|
136
147
|
licenses:
|
|
137
148
|
- MIT
|