tigerbeetle 0.16.28__py3-none-any.whl → 0.16.30__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 +41 -17
- 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.28.dist-info → tigerbeetle-0.16.30.dist-info}/METADATA +1 -1
- tigerbeetle-0.16.30.dist-info/RECORD +14 -0
- tigerbeetle-0.16.28.dist-info/RECORD +0 -14
- {tigerbeetle-0.16.28.dist-info → tigerbeetle-0.16.30.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
|
|
@@ -274,25 +285,38 @@ class CPacket(ctypes.Structure):
|
|
|
274
285
|
@classmethod
|
|
275
286
|
def from_param(cls, obj):
|
|
276
287
|
validate_uint(bits=32, name="data_size", number=obj.data_size)
|
|
277
|
-
validate_uint(bits=16, name="
|
|
288
|
+
validate_uint(bits=16, name="user_tag", number=obj.user_tag)
|
|
278
289
|
validate_uint(bits=8, name="operation", number=obj.operation)
|
|
279
290
|
return cls(
|
|
280
291
|
user_data=obj.user_data,
|
|
281
292
|
data=obj.data,
|
|
282
293
|
data_size=obj.data_size,
|
|
283
|
-
|
|
294
|
+
user_tag=obj.user_tag,
|
|
284
295
|
operation=obj.operation,
|
|
285
296
|
status=obj.status,
|
|
297
|
+
opaque=obj.opaque,
|
|
286
298
|
)
|
|
287
299
|
|
|
288
300
|
CPacket._fields_ = [ # noqa: SLF001
|
|
289
301
|
("user_data", ctypes.c_void_p),
|
|
290
302
|
("data", ctypes.c_void_p),
|
|
291
303
|
("data_size", ctypes.c_uint32),
|
|
292
|
-
("
|
|
304
|
+
("user_tag", ctypes.c_uint16),
|
|
293
305
|
("operation", ctypes.c_uint8),
|
|
294
306
|
("status", ctypes.c_uint8),
|
|
295
|
-
("
|
|
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),
|
|
296
320
|
]
|
|
297
321
|
|
|
298
322
|
|
|
@@ -608,22 +632,22 @@ CQueryFilter._fields_ = [ # noqa: SLF001
|
|
|
608
632
|
|
|
609
633
|
|
|
610
634
|
# Don't be tempted to use c_char_p for bytes_ptr - it's for null terminated strings only.
|
|
611
|
-
OnCompletion = ctypes.CFUNCTYPE(None, ctypes.c_void_p,
|
|
635
|
+
OnCompletion = ctypes.CFUNCTYPE(None, ctypes.c_void_p, ctypes.POINTER(CPacket),
|
|
612
636
|
ctypes.c_uint64, ctypes.c_void_p, ctypes.c_uint32)
|
|
613
|
-
LogHandler = ctypes.CFUNCTYPE(None, ctypes.
|
|
637
|
+
LogHandler = ctypes.CFUNCTYPE(None, ctypes.c_uint, ctypes.c_void_p, ctypes.c_uint)
|
|
614
638
|
|
|
615
639
|
# Initialize a new TigerBeetle client which connects to the addresses provided and
|
|
616
640
|
# completes submitted packets by invoking the callback with the given context.
|
|
617
641
|
tb_client_init = tbclient.tb_client_init
|
|
618
|
-
tb_client_init.restype =
|
|
619
|
-
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),
|
|
620
644
|
ctypes.c_char_p, ctypes.c_uint32, ctypes.c_void_p,
|
|
621
645
|
OnCompletion]
|
|
622
646
|
|
|
623
647
|
# Initialize a new TigerBeetle client which echos back any data submitted.
|
|
624
648
|
tb_client_init_echo = tbclient.tb_client_init_echo
|
|
625
|
-
tb_client_init_echo.restype =
|
|
626
|
-
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),
|
|
627
651
|
ctypes.c_char_p, ctypes.c_uint32, ctypes.c_void_p,
|
|
628
652
|
OnCompletion]
|
|
629
653
|
|
|
@@ -631,15 +655,15 @@ tb_client_init_echo.argtypes = [ctypes.POINTER(Client), ctypes.POINTER(ctypes.c_
|
|
|
631
655
|
# `TB_PACKET_CLIENT_SHUTDOWN` before freeing any allocated client resources from init.
|
|
632
656
|
# It is undefined behavior to use any functions on the client once deinit is called.
|
|
633
657
|
tb_client_deinit = tbclient.tb_client_deinit
|
|
634
|
-
tb_client_deinit.restype =
|
|
635
|
-
tb_client_deinit.argtypes = [
|
|
658
|
+
tb_client_deinit.restype = ClientStatus
|
|
659
|
+
tb_client_deinit.argtypes = [ctypes.POINTER(CClient)]
|
|
636
660
|
|
|
637
661
|
# Submit a packet with its operation, data, and data_size fields set.
|
|
638
662
|
# Once completed, `on_completion` will be invoked with `on_completion_ctx` and the given
|
|
639
663
|
# packet on the `tb_client` thread (separate from caller's thread).
|
|
640
664
|
tb_client_submit = tbclient.tb_client_submit
|
|
641
|
-
tb_client_submit.restype =
|
|
642
|
-
tb_client_submit.argtypes = [
|
|
665
|
+
tb_client_submit.restype = ClientStatus
|
|
666
|
+
tb_client_submit.argtypes = [ctypes.POINTER(CClient), ctypes.POINTER(CPacket)]
|
|
643
667
|
|
|
644
668
|
tb_client_register_log_callback = tbclient.tb_client_register_log_callback
|
|
645
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=J8vRVupMHqubbADlCGVrhecRLoXpvWellJPembUGv8w,3908576
|
|
6
|
+
tigerbeetle/lib/aarch64-linux-musl/libtb_client.so,sha256=wT6Oo8s2Zr_hVL6CGs7gVkP2xCAz9LnD7G1vqHCYrDI,3885320
|
|
7
|
+
tigerbeetle/lib/aarch64-macos/libtb_client.dylib,sha256=lGxwbM-mDoAzqJt6bXYMKDUVkfHJFVfKraEjKz5bmqY,535312
|
|
8
|
+
tigerbeetle/lib/x86_64-linux-gnu.2.27/libtb_client.so,sha256=DZJRfKVaPzWxNoq49pUAXAQPYeqF23A_UFhFBYC6aWk,3853376
|
|
9
|
+
tigerbeetle/lib/x86_64-linux-musl/libtb_client.so,sha256=JVmeXbXszh_q0Zz-QT6j1z1ltr6BpxZ6B0pG3xWERRQ,3850416
|
|
10
|
+
tigerbeetle/lib/x86_64-macos/libtb_client.dylib,sha256=I5a65QJNokQOfVhN3sWG4IuJp-WS9jzGU3fZ28K2ano,747631
|
|
11
|
+
tigerbeetle/lib/x86_64-windows/tb_client.dll,sha256=hzjk4gSh9bo4dxQriN9RKB55CPIuboGDf2Dgow1ui0M,832512
|
|
12
|
+
tigerbeetle-0.16.30.dist-info/METADATA,sha256=EgNUoY3Jh-Xg39eXEwb5WsYy_PVmcgPRAHSIlwffrLA,22957
|
|
13
|
+
tigerbeetle-0.16.30.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
14
|
+
tigerbeetle-0.16.30.dist-info/RECORD,,
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
tigerbeetle/__init__.py,sha256=3cmov0HPkByJw1znLKoTqIuZUEeEQMEg1fflWY3ty9A,168
|
|
2
|
-
tigerbeetle/bindings.py,sha256=P7BDB1nq72D-fL6FhqBpCGfVX2FPore6x3T1d4JTiKk,25990
|
|
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=-f3dgm0y557BKAXHjZyzFazHpeWr4pN3SVLNmGbWAjA,3751112
|
|
6
|
-
tigerbeetle/lib/aarch64-linux-musl/libtb_client.so,sha256=8sBQU1R2la_AjZ7jh3p3CnafGh-i9J-dNxNx_elVYiY,3728360
|
|
7
|
-
tigerbeetle/lib/aarch64-macos/libtb_client.dylib,sha256=HebPPhGsAYhZnTPHt9glx-EzFiOZjmeGc8rBsBjGA8k,516960
|
|
8
|
-
tigerbeetle/lib/x86_64-linux-gnu.2.27/libtb_client.so,sha256=AnMz89Xbz2kDLWHh8srW4ZRRn77nJmxKc2NX8nqZB8I,3667392
|
|
9
|
-
tigerbeetle/lib/x86_64-linux-musl/libtb_client.so,sha256=GzBbQn5CguA3uO_YJqYVG5Hw4QEE5g3RJfxoMaGzJ1M,3664384
|
|
10
|
-
tigerbeetle/lib/x86_64-macos/libtb_client.dylib,sha256=zfEDtF2CIoFNjmZit9cpiNTZHtGfL3giGCTOU8HJO5I,729284
|
|
11
|
-
tigerbeetle/lib/x86_64-windows/tb_client.dll,sha256=C2jKv4vz8-QKKg5KcUjTGJCes_3btEagnnvMsqsEJRc,820224
|
|
12
|
-
tigerbeetle-0.16.28.dist-info/METADATA,sha256=dSXrE44EK9PIoQ1KU2PMuXW8Te9aDZ0_BeUon0OKr7c,22957
|
|
13
|
-
tigerbeetle-0.16.28.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
14
|
-
tigerbeetle-0.16.28.dist-info/RECORD,,
|
|
File without changes
|