tigerbeetle 0.16.27__py3-none-any.whl → 0.16.29__py3-none-any.whl
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.
Potentially problematic release.
This version of tigerbeetle might be problematic. Click here for more details.
- tigerbeetle/bindings.py +46 -30
- tigerbeetle/client.py +24 -13
- tigerbeetle/lib/aarch64-linux-gnu.2.27/libtb_client.so +0 -0
- tigerbeetle/lib/aarch64-linux-musl/libtb_client.so +0 -0
- tigerbeetle/lib/aarch64-macos/libtb_client.dylib +0 -0
- tigerbeetle/lib/x86_64-linux-gnu.2.27/libtb_client.so +0 -0
- tigerbeetle/lib/x86_64-linux-musl/libtb_client.so +0 -0
- tigerbeetle/lib/x86_64-macos/libtb_client.dylib +0 -0
- tigerbeetle/lib/x86_64-windows/tb_client.dll +0 -0
- {tigerbeetle-0.16.27.dist-info → tigerbeetle-0.16.29.dist-info}/METADATA +1 -1
- tigerbeetle-0.16.29.dist-info/RECORD +14 -0
- tigerbeetle-0.16.27.dist-info/RECORD +0 -14
- {tigerbeetle-0.16.27.dist-info → tigerbeetle-0.16.29.dist-info}/WHEEL +0 -0
tigerbeetle/bindings.py
CHANGED
|
@@ -22,6 +22,7 @@ class Operation(enum.IntEnum):
|
|
|
22
22
|
GET_ACCOUNT_BALANCES = 134
|
|
23
23
|
QUERY_ACCOUNTS = 135
|
|
24
24
|
QUERY_TRANSFERS = 136
|
|
25
|
+
GET_EVENTS = 137
|
|
25
26
|
|
|
26
27
|
|
|
27
28
|
class PacketStatus(enum.IntEnum):
|
|
@@ -35,9 +36,7 @@ class PacketStatus(enum.IntEnum):
|
|
|
35
36
|
INVALID_DATA_SIZE = 7
|
|
36
37
|
|
|
37
38
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
class Status(enum.IntEnum):
|
|
39
|
+
class InitStatus(enum.IntEnum):
|
|
41
40
|
SUCCESS = 0
|
|
42
41
|
UNEXPECTED = 1
|
|
43
42
|
OUT_OF_MEMORY = 2
|
|
@@ -47,6 +46,18 @@ class Status(enum.IntEnum):
|
|
|
47
46
|
NETWORK_SUBSYSTEM = 6
|
|
48
47
|
|
|
49
48
|
|
|
49
|
+
class ClientStatus(enum.IntEnum):
|
|
50
|
+
OK = 0
|
|
51
|
+
INVALID = 1
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
class LogLevel(enum.IntEnum):
|
|
55
|
+
ERR = 0
|
|
56
|
+
WARN = 1
|
|
57
|
+
INFO = 2
|
|
58
|
+
DEBUG = 3
|
|
59
|
+
|
|
60
|
+
|
|
50
61
|
class RegisterLogCallbackStatus(enum.IntEnum):
|
|
51
62
|
SUCCESS = 0
|
|
52
63
|
ALREADY_REGISTERED = 1
|
|
@@ -273,34 +284,39 @@ class QueryFilter:
|
|
|
273
284
|
class CPacket(ctypes.Structure):
|
|
274
285
|
@classmethod
|
|
275
286
|
def from_param(cls, obj):
|
|
276
|
-
validate_uint(bits=8, name="operation", number=obj.operation)
|
|
277
287
|
validate_uint(bits=32, name="data_size", number=obj.data_size)
|
|
278
|
-
validate_uint(bits=
|
|
288
|
+
validate_uint(bits=16, name="user_tag", number=obj.user_tag)
|
|
289
|
+
validate_uint(bits=8, name="operation", number=obj.operation)
|
|
279
290
|
return cls(
|
|
280
|
-
next=obj.next,
|
|
281
291
|
user_data=obj.user_data,
|
|
292
|
+
data=obj.data,
|
|
293
|
+
data_size=obj.data_size,
|
|
294
|
+
user_tag=obj.user_tag,
|
|
282
295
|
operation=obj.operation,
|
|
283
296
|
status=obj.status,
|
|
284
|
-
|
|
285
|
-
data=obj.data,
|
|
286
|
-
batch_next=obj.batch_next,
|
|
287
|
-
batch_tail=obj.batch_tail,
|
|
288
|
-
batch_size=obj.batch_size,
|
|
289
|
-
batch_allowed=obj.batch_allowed,
|
|
297
|
+
opaque=obj.opaque,
|
|
290
298
|
)
|
|
291
299
|
|
|
292
300
|
CPacket._fields_ = [ # noqa: SLF001
|
|
293
|
-
("next", ctypes.POINTER(CPacket)),
|
|
294
301
|
("user_data", ctypes.c_void_p),
|
|
302
|
+
("data", ctypes.c_void_p),
|
|
303
|
+
("data_size", ctypes.c_uint32),
|
|
304
|
+
("user_tag", ctypes.c_uint16),
|
|
295
305
|
("operation", ctypes.c_uint8),
|
|
296
306
|
("status", ctypes.c_uint8),
|
|
297
|
-
("
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
(
|
|
307
|
+
("opaque", ctypes.c_uint8 * 32),
|
|
308
|
+
]
|
|
309
|
+
|
|
310
|
+
|
|
311
|
+
class CClient(ctypes.Structure):
|
|
312
|
+
@classmethod
|
|
313
|
+
def from_param(cls, obj):
|
|
314
|
+
return cls(
|
|
315
|
+
opaque=obj.opaque,
|
|
316
|
+
)
|
|
317
|
+
|
|
318
|
+
CClient._fields_ = [ # noqa: SLF001
|
|
319
|
+
("opaque", ctypes.c_uint64 * 4),
|
|
304
320
|
]
|
|
305
321
|
|
|
306
322
|
|
|
@@ -616,22 +632,22 @@ CQueryFilter._fields_ = [ # noqa: SLF001
|
|
|
616
632
|
|
|
617
633
|
|
|
618
634
|
# Don't be tempted to use c_char_p for bytes_ptr - it's for null terminated strings only.
|
|
619
|
-
OnCompletion = ctypes.CFUNCTYPE(None, ctypes.c_void_p,
|
|
635
|
+
OnCompletion = ctypes.CFUNCTYPE(None, ctypes.c_void_p, ctypes.POINTER(CPacket),
|
|
620
636
|
ctypes.c_uint64, ctypes.c_void_p, ctypes.c_uint32)
|
|
621
|
-
LogHandler = ctypes.CFUNCTYPE(None, ctypes.
|
|
637
|
+
LogHandler = ctypes.CFUNCTYPE(None, ctypes.c_uint, ctypes.c_void_p, ctypes.c_uint)
|
|
622
638
|
|
|
623
639
|
# Initialize a new TigerBeetle client which connects to the addresses provided and
|
|
624
640
|
# completes submitted packets by invoking the callback with the given context.
|
|
625
641
|
tb_client_init = tbclient.tb_client_init
|
|
626
|
-
tb_client_init.restype =
|
|
627
|
-
tb_client_init.argtypes = [ctypes.POINTER(
|
|
642
|
+
tb_client_init.restype = InitStatus
|
|
643
|
+
tb_client_init.argtypes = [ctypes.POINTER(CClient), ctypes.POINTER(ctypes.c_uint8 * 16),
|
|
628
644
|
ctypes.c_char_p, ctypes.c_uint32, ctypes.c_void_p,
|
|
629
645
|
OnCompletion]
|
|
630
646
|
|
|
631
647
|
# Initialize a new TigerBeetle client which echos back any data submitted.
|
|
632
648
|
tb_client_init_echo = tbclient.tb_client_init_echo
|
|
633
|
-
tb_client_init_echo.restype =
|
|
634
|
-
tb_client_init_echo.argtypes = [ctypes.POINTER(
|
|
649
|
+
tb_client_init_echo.restype = InitStatus
|
|
650
|
+
tb_client_init_echo.argtypes = [ctypes.POINTER(CClient), ctypes.POINTER(ctypes.c_uint8 * 16),
|
|
635
651
|
ctypes.c_char_p, ctypes.c_uint32, ctypes.c_void_p,
|
|
636
652
|
OnCompletion]
|
|
637
653
|
|
|
@@ -639,15 +655,15 @@ tb_client_init_echo.argtypes = [ctypes.POINTER(Client), ctypes.POINTER(ctypes.c_
|
|
|
639
655
|
# `TB_PACKET_CLIENT_SHUTDOWN` before freeing any allocated client resources from init.
|
|
640
656
|
# It is undefined behavior to use any functions on the client once deinit is called.
|
|
641
657
|
tb_client_deinit = tbclient.tb_client_deinit
|
|
642
|
-
tb_client_deinit.restype =
|
|
643
|
-
tb_client_deinit.argtypes = [
|
|
658
|
+
tb_client_deinit.restype = ClientStatus
|
|
659
|
+
tb_client_deinit.argtypes = [ctypes.POINTER(CClient)]
|
|
644
660
|
|
|
645
661
|
# Submit a packet with its operation, data, and data_size fields set.
|
|
646
662
|
# Once completed, `on_completion` will be invoked with `on_completion_ctx` and the given
|
|
647
663
|
# packet on the `tb_client` thread (separate from caller's thread).
|
|
648
664
|
tb_client_submit = tbclient.tb_client_submit
|
|
649
|
-
tb_client_submit.restype =
|
|
650
|
-
tb_client_submit.argtypes = [
|
|
665
|
+
tb_client_submit.restype = ClientStatus
|
|
666
|
+
tb_client_submit.argtypes = [ctypes.POINTER(CClient), ctypes.POINTER(CPacket)]
|
|
651
667
|
|
|
652
668
|
tb_client_register_log_callback = tbclient.tb_client_register_log_callback
|
|
653
669
|
tb_client_register_log_callback.restype = RegisterLogCallbackStatus
|
tigerbeetle/client.py
CHANGED
|
@@ -77,6 +77,9 @@ amount_max = (2 ** 128) - 1
|
|
|
77
77
|
class InitError(Exception):
|
|
78
78
|
pass
|
|
79
79
|
|
|
80
|
+
class ClientClosedError(Exception):
|
|
81
|
+
pass
|
|
82
|
+
|
|
80
83
|
class PacketError(Exception):
|
|
81
84
|
pass
|
|
82
85
|
|
|
@@ -87,7 +90,7 @@ class Client:
|
|
|
87
90
|
|
|
88
91
|
def __init__(self, cluster_id: int, replica_addresses: str):
|
|
89
92
|
self._client_key = Client._counter.increment()
|
|
90
|
-
self._client = bindings.
|
|
93
|
+
self._client = bindings.CClient()
|
|
91
94
|
|
|
92
95
|
self._inflight_packets: dict[int, InflightPacket] = {}
|
|
93
96
|
|
|
@@ -104,7 +107,7 @@ class Client:
|
|
|
104
107
|
self._client_key,
|
|
105
108
|
self._c_on_completion
|
|
106
109
|
)
|
|
107
|
-
if init_status != bindings.
|
|
110
|
+
if init_status != bindings.InitStatus.SUCCESS:
|
|
108
111
|
raise InitError(init_status)
|
|
109
112
|
|
|
110
113
|
Client._clients[self._client_key] = self
|
|
@@ -115,6 +118,7 @@ class Client:
|
|
|
115
118
|
packet = bindings.CPacket()
|
|
116
119
|
packet.next = None
|
|
117
120
|
packet.user_data = Client._counter.increment()
|
|
121
|
+
packet.user_tag = 0
|
|
118
122
|
packet.operation = operation
|
|
119
123
|
packet.status = bindings.PacketStatus.OK
|
|
120
124
|
|
|
@@ -134,19 +138,18 @@ class Client:
|
|
|
134
138
|
c_result_type=c_result_type)
|
|
135
139
|
|
|
136
140
|
def close(self):
|
|
137
|
-
bindings.tb_client_deinit(self._client)
|
|
141
|
+
bindings.tb_client_deinit(ctypes.byref(self._client))
|
|
138
142
|
tb_assert(self._client is not None)
|
|
139
143
|
tb_assert(len(self._inflight_packets) == 0)
|
|
140
144
|
del Client._clients[self._client_key]
|
|
141
145
|
|
|
142
146
|
@staticmethod
|
|
143
147
|
@bindings.OnCompletion
|
|
144
|
-
def _c_on_completion(completion_ctx,
|
|
148
|
+
def _c_on_completion(completion_ctx, packet, timestamp, bytes_ptr, len_):
|
|
145
149
|
"""
|
|
146
150
|
Invoked in a separate thread
|
|
147
151
|
"""
|
|
148
152
|
self: Client = Client._clients[completion_ctx]
|
|
149
|
-
tb_assert(self._client.value == tb_client)
|
|
150
153
|
|
|
151
154
|
packet = ctypes.cast(packet, ctypes.POINTER(bindings.CPacket))
|
|
152
155
|
inflight_packet = self._inflight_packets[packet[0].user_data]
|
|
@@ -193,11 +196,15 @@ class ClientSync(Client, bindings.StateMachineMixin):
|
|
|
193
196
|
inflight_packet.on_completion = self._on_completion
|
|
194
197
|
inflight_packet.on_completion_context = CompletionContextSync(event=threading.Event())
|
|
195
198
|
|
|
196
|
-
bindings.tb_client_submit(self._client, ctypes.byref(inflight_packet.packet))
|
|
197
|
-
|
|
199
|
+
client_state = bindings.tb_client_submit(ctypes.byref(self._client), ctypes.byref(inflight_packet.packet))
|
|
200
|
+
if client_state == bindings.ClientStatus.OK:
|
|
201
|
+
inflight_packet.on_completion_context.event.wait()
|
|
198
202
|
|
|
199
203
|
del self._inflight_packets[inflight_packet.packet.user_data]
|
|
200
204
|
|
|
205
|
+
if client_state == bindings.ClientStatus.INVALID:
|
|
206
|
+
raise ClientClosedError()
|
|
207
|
+
|
|
201
208
|
if isinstance(inflight_packet.response, Exception):
|
|
202
209
|
raise inflight_packet.response
|
|
203
210
|
|
|
@@ -230,11 +237,15 @@ class ClientAsync(Client, bindings.AsyncStateMachineMixin):
|
|
|
230
237
|
event=asyncio.Event()
|
|
231
238
|
)
|
|
232
239
|
|
|
233
|
-
bindings.tb_client_submit(self._client, ctypes.byref(inflight_packet.packet))
|
|
234
|
-
|
|
240
|
+
client_state = bindings.tb_client_submit(ctypes.byref(self._client), ctypes.byref(inflight_packet.packet))
|
|
241
|
+
if client_state == bindings.ClientStatus.OK:
|
|
242
|
+
await inflight_packet.on_completion_context.event.wait()
|
|
235
243
|
|
|
236
244
|
del self._inflight_packets[inflight_packet.packet.user_data]
|
|
237
245
|
|
|
246
|
+
if client_state == bindings.ClientStatus.INVALID:
|
|
247
|
+
raise ClientClosedError()
|
|
248
|
+
|
|
238
249
|
if isinstance(inflight_packet.response, Exception):
|
|
239
250
|
raise inflight_packet.response
|
|
240
251
|
|
|
@@ -244,10 +255,10 @@ class ClientAsync(Client, bindings.AsyncStateMachineMixin):
|
|
|
244
255
|
@bindings.LogHandler
|
|
245
256
|
def log_handler(level_zig, message_ptr, message_len):
|
|
246
257
|
level_python = {
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
258
|
+
bindings.LogLevel.ERR: logging.ERROR,
|
|
259
|
+
bindings.LogLevel.WARN: logging.WARNING,
|
|
260
|
+
bindings.LogLevel.INFO: logging.INFO,
|
|
261
|
+
bindings.LogLevel.DEBUG: logging.DEBUG,
|
|
251
262
|
}[level_zig]
|
|
252
263
|
logger.log(level_python, ctypes.string_at(message_ptr, message_len).decode("utf-8"))
|
|
253
264
|
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
tigerbeetle/__init__.py,sha256=3cmov0HPkByJw1znLKoTqIuZUEeEQMEg1fflWY3ty9A,168
|
|
2
|
+
tigerbeetle/bindings.py,sha256=8YfOv18KBGvLkkfhMiUFAuwCCzkhdgKg9-kuI80rW44,26460
|
|
3
|
+
tigerbeetle/client.py,sha256=oGg1vAFqI8UZ5awI3sshZfxUdBsroUKwgp2rUa75lFc,9255
|
|
4
|
+
tigerbeetle/lib.py,sha256=JKreDxdw_YejtH7F135_m6I6mNBSwjokaI6QicKm7cc,2425
|
|
5
|
+
tigerbeetle/lib/aarch64-linux-gnu.2.27/libtb_client.so,sha256=9H4irv3j7WGsp97OFOESDYjkcrCAbAqavs0qUBJo36A,3882600
|
|
6
|
+
tigerbeetle/lib/aarch64-linux-musl/libtb_client.so,sha256=fztP2HOQGv4e297kUhMJGfTr5iuBthij6L8Tqqe17Yk,3859344
|
|
7
|
+
tigerbeetle/lib/aarch64-macos/libtb_client.dylib,sha256=WtlycdXHng6WURVstdZwwqBMtGLupSTacjq8mWeYNXw,534944
|
|
8
|
+
tigerbeetle/lib/x86_64-linux-gnu.2.27/libtb_client.so,sha256=NiQMmn8L7ji5K_tkM84z8sib6IZoD88-S7AqXkyTHPk,3824296
|
|
9
|
+
tigerbeetle/lib/x86_64-linux-musl/libtb_client.so,sha256=KPN4nl73s35aE7d9bWi9qSh2Z6Dv3ieQ8nax_96AVuA,3821328
|
|
10
|
+
tigerbeetle/lib/x86_64-macos/libtb_client.dylib,sha256=leFoiEen_wjSCZr1Qrfxwf6mSGXyesGyqdmeQC4NgGQ,743167
|
|
11
|
+
tigerbeetle/lib/x86_64-windows/tb_client.dll,sha256=M4uCwkVXA1r96CGNotF3gkaX7BoNNNBFK8cmLCUxeWM,829440
|
|
12
|
+
tigerbeetle-0.16.29.dist-info/METADATA,sha256=ukDiaZOp_bowNIAa1bxJy5yIlcOIYW3BSdFD_AI8KVs,22957
|
|
13
|
+
tigerbeetle-0.16.29.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
14
|
+
tigerbeetle-0.16.29.dist-info/RECORD,,
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
tigerbeetle/__init__.py,sha256=3cmov0HPkByJw1znLKoTqIuZUEeEQMEg1fflWY3ty9A,168
|
|
2
|
-
tigerbeetle/bindings.py,sha256=K3rgGuiH6kHO1rZOypk32S06O5OfHYHwLA2KQOyG2BM,26341
|
|
3
|
-
tigerbeetle/client.py,sha256=sniZ6IATiAGWgtRrd60Xtfcixw4cMOaVZEUUP6sFfzM,8774
|
|
4
|
-
tigerbeetle/lib.py,sha256=JKreDxdw_YejtH7F135_m6I6mNBSwjokaI6QicKm7cc,2425
|
|
5
|
-
tigerbeetle/lib/aarch64-linux-gnu.2.27/libtb_client.so,sha256=u1hdl8OGFE-MeOQ-xPFTsXVJFEzrmxnBefWgmS9hW4E,3720048
|
|
6
|
-
tigerbeetle/lib/aarch64-linux-musl/libtb_client.so,sha256=xI452cs1BpyHJb3ECyeMfDXua2WyyxZYQyxLc2A2IOg,3697280
|
|
7
|
-
tigerbeetle/lib/aarch64-macos/libtb_client.dylib,sha256=EDqGJeoZkJ10NaPJtPQgPmPjBWgQmPfKyUjM5q8y0LU,515904
|
|
8
|
-
tigerbeetle/lib/x86_64-linux-gnu.2.27/libtb_client.so,sha256=hVH2FXtsjOsGuPe1QicLsacp6hWCq43mL_RqH00fIXw,3634360
|
|
9
|
-
tigerbeetle/lib/x86_64-linux-musl/libtb_client.so,sha256=aF5mbrS5BZKuUVSuoBVAsAwXX-cxztve_5bCpJ7BWzE,3631360
|
|
10
|
-
tigerbeetle/lib/x86_64-macos/libtb_client.dylib,sha256=2aYZBmg_UAHX8k7xAsZM9f-6VP8ug7ko_BtFxiuqDK4,724116
|
|
11
|
-
tigerbeetle/lib/x86_64-windows/tb_client.dll,sha256=o3iM89v-grxHii6GOtzUC08pJXz82328Wb_OFctCXpE,815104
|
|
12
|
-
tigerbeetle-0.16.27.dist-info/METADATA,sha256=8JIM4XtOLdPgCZJ049DRXPqROphx1t5zZSssvPJR5Zk,22957
|
|
13
|
-
tigerbeetle-0.16.27.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
14
|
-
tigerbeetle-0.16.27.dist-info/RECORD,,
|
|
File without changes
|