tigerbeetle 0.16.18__py3-none-any.whl → 0.16.19__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.
tigerbeetle/__init__.py CHANGED
@@ -1,3 +1,3 @@
1
1
  from .bindings import * # noqa
2
- from .client import ClientAsync, ClientSync, id, amount_max # noqa
2
+ from .client import ClientAsync, ClientSync, id, amount_max, configure_logging # noqa
3
3
  from .lib import IntegerOverflowError, NativeError
tigerbeetle/bindings.py CHANGED
@@ -47,6 +47,12 @@ class Status(enum.IntEnum):
47
47
  NETWORK_SUBSYSTEM = 6
48
48
 
49
49
 
50
+ class RegisterLogCallbackStatus(enum.IntEnum):
51
+ SUCCESS = 0
52
+ ALREADY_REGISTERED = 1
53
+ NOT_REGISTERED = 2
54
+
55
+
50
56
  class AccountFlags(enum.IntFlag):
51
57
  NONE = 0
52
58
  LINKED = 1 << 0
@@ -612,6 +618,7 @@ CQueryFilter._fields_ = [ # noqa: SLF001
612
618
  # Don't be tempted to use c_char_p for bytes_ptr - it's for null terminated strings only.
613
619
  OnCompletion = ctypes.CFUNCTYPE(None, ctypes.c_void_p, Client, ctypes.POINTER(CPacket),
614
620
  ctypes.c_uint64, ctypes.c_void_p, ctypes.c_uint32)
621
+ LogHandler = ctypes.CFUNCTYPE(None, ctypes.c_uint8, ctypes.c_void_p, ctypes.c_uint)
615
622
 
616
623
  # Initialize a new TigerBeetle client which connects to the addresses provided and
617
624
  # completes submitted packets by invoking the callback with the given context.
@@ -641,6 +648,13 @@ tb_client_deinit.argtypes = [Client]
641
648
  tb_client_submit = tbclient.tb_client_submit
642
649
  tb_client_submit.restype = None
643
650
  tb_client_submit.argtypes = [Client, ctypes.POINTER(CPacket)]
651
+
652
+ tb_client_register_log_callback = tbclient.tb_client_register_log_callback
653
+ tb_client_register_log_callback.restype = RegisterLogCallbackStatus
654
+ # Need to pass in None to clear - ctypes will error if argtypes is set.
655
+ #tb_client_register_log_callback.argtypes = [LogHandler, ctypes.c_bool]
656
+
657
+
644
658
  class AsyncStateMachineMixin:
645
659
  _submit: Callable[[Operation, Any, Any, Any], Any]
646
660
  async def create_accounts(self, accounts: list[Account]) -> list[CreateAccountsResult]:
tigerbeetle/client.py CHANGED
@@ -236,3 +236,25 @@ class ClientAsync(Client, bindings.AsyncStateMachineMixin):
236
236
  raise inflight_packet.response
237
237
 
238
238
  return inflight_packet.response
239
+
240
+
241
+ @bindings.LogHandler
242
+ def log_handler(level_zig, message_ptr, message_len):
243
+ level_python = {
244
+ 0: logging.ERROR,
245
+ 1: logging.WARNING,
246
+ 2: logging.INFO,
247
+ 3: logging.DEBUG,
248
+ }[level_zig]
249
+ logger.log(level_python, ctypes.string_at(message_ptr, message_len).decode("utf-8"))
250
+
251
+ tb_assert(bindings.tb_client_register_log_callback(log_handler, True) ==
252
+ bindings.RegisterLogCallbackStatus.SUCCESS)
253
+
254
+ def configure_logging(*, debug, log_handler=log_handler):
255
+ # First disable the existing log handler, before enabling the new one.
256
+ tb_assert(bindings.tb_client_register_log_callback(None, debug) ==
257
+ bindings.RegisterLogCallbackStatus.SUCCESS)
258
+
259
+ tb_assert(bindings.tb_client_register_log_callback(log_handler, debug) ==
260
+ bindings.RegisterLogCallbackStatus.SUCCESS)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: tigerbeetle
3
- Version: 0.16.18
3
+ Version: 0.16.19
4
4
  Summary: The TigerBeetle client for Python.
5
5
  Project-URL: Homepage, https://github.com/tigerbeetle/tigerbeetle
6
6
  Project-URL: Issues, https://github.com/tigerbeetle/tigerbeetle/issues
@@ -47,6 +47,10 @@ import os
47
47
  import tigerbeetle as tb
48
48
 
49
49
  print("Import OK!")
50
+
51
+ # To enable debug logging, via Python's built in logging module:
52
+ # logging.basicConfig(level=logging.DEBUG)
53
+ # tb.configure_logging(debug=True)
50
54
  ```
51
55
 
52
56
  Finally, build and run:
@@ -0,0 +1,14 @@
1
+ tigerbeetle/__init__.py,sha256=3cmov0HPkByJw1znLKoTqIuZUEeEQMEg1fflWY3ty9A,168
2
+ tigerbeetle/bindings.py,sha256=K3rgGuiH6kHO1rZOypk32S06O5OfHYHwLA2KQOyG2BM,26341
3
+ tigerbeetle/client.py,sha256=Xm9WumDj_aN3DVAnX7N3P1dT4QOT7LW91VrJQ-era6o,8588
4
+ tigerbeetle/lib.py,sha256=JKreDxdw_YejtH7F135_m6I6mNBSwjokaI6QicKm7cc,2425
5
+ tigerbeetle/lib/aarch64-linux-gnu.2.27/libtb_client.so,sha256=qx8DILqLjglR-Sn5tPBUu1k5BCz7tIWep9iGFfSvauQ,3676440
6
+ tigerbeetle/lib/aarch64-linux-musl/libtb_client.so,sha256=Fx9lIIn8WvuOW6qNjz5aBBBx5VIAg2ozT3fzFGouHF8,3653256
7
+ tigerbeetle/lib/aarch64-macos/libtb_client.dylib,sha256=lEmuxwV3AgRpGKu7VkFb2tFN7jXsEgLMeD0df1mhA1c,516336
8
+ tigerbeetle/lib/x86_64-linux-gnu.2.27/libtb_client.so,sha256=lAacu-usVbIOf6nAj_fW44Uj-6xEXMa_ThwCPTnmoFU,3591640
9
+ tigerbeetle/lib/x86_64-linux-musl/libtb_client.so,sha256=aa8TYkLhWerwJPfpT9iXYYIF2VCiWgcEHQUak7DDLOg,3588672
10
+ tigerbeetle/lib/x86_64-macos/libtb_client.dylib,sha256=y68dzVEXXI53kSdpWAEBJOgwSDugZWwkHMEJSEdax1I,716357
11
+ tigerbeetle/lib/x86_64-windows/tb_client.dll,sha256=4ce6L5QV_FEYvi2_KuyseksC23jOs0Y0Cls6cwT0xRE,819712
12
+ tigerbeetle-0.16.19.dist-info/METADATA,sha256=_BnbKcln6SPQXFt9MRg9O15Qm4GXsCNR5bXX9pl7rgA,22980
13
+ tigerbeetle-0.16.19.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
14
+ tigerbeetle-0.16.19.dist-info/RECORD,,
@@ -1,14 +0,0 @@
1
- tigerbeetle/__init__.py,sha256=3B2UoTndlx7dViX1_TU4qM98pDzFjB6SujEsEdV4As8,149
2
- tigerbeetle/bindings.py,sha256=-pxQLQZyJUd8Ym3Gq9ssWb-zaSdFnG0_6XD6_BrXiaY,25852
3
- tigerbeetle/client.py,sha256=eRrbTcAKN4n0mRvQNYn1i3C7-JNr-UHYiwLzIWvsyG0,7769
4
- tigerbeetle/lib.py,sha256=JKreDxdw_YejtH7F135_m6I6mNBSwjokaI6QicKm7cc,2425
5
- tigerbeetle/lib/aarch64-linux-gnu.2.27/libtb_client.so,sha256=AfQTo2OAEB2giVwBw-fd_Fp_IJa9GKwLAazOCIDTGtM,3676336
6
- tigerbeetle/lib/aarch64-linux-musl/libtb_client.so,sha256=ePMRmEw7_iXw4uDPmWbxBSWXbzeUw4kivZYGGFkgM_g,3653136
7
- tigerbeetle/lib/aarch64-macos/libtb_client.dylib,sha256=Je5BNXpQn1C8gKMwEtlBmeeb-Q_1TnA1PkT-NaypXs4,516336
8
- tigerbeetle/lib/x86_64-linux-gnu.2.27/libtb_client.so,sha256=PFigzsxo1wbCYi-7Rzwj7RYqhyRDiA5XfY8E-SvBGIo,3591608
9
- tigerbeetle/lib/x86_64-linux-musl/libtb_client.so,sha256=WbwuthMOp6N_NIcOdNlnF0ZN672_gsWuXRfjJZ0bjRQ,3588648
10
- tigerbeetle/lib/x86_64-macos/libtb_client.dylib,sha256=wDi4ved2vGtL2qAoyt9DJCdqrILGzIkhodT7dQh2nzY,716357
11
- tigerbeetle/lib/x86_64-windows/tb_client.dll,sha256=YCtVxz0kevVRsD4zdInugVMFIAY-qevRRKtt3mrkOks,819712
12
- tigerbeetle-0.16.18.dist-info/METADATA,sha256=6cIXmu3YRO2mDhwjrq4-pJ42hPHBb2DsclwIEr_0zWE,22836
13
- tigerbeetle-0.16.18.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
14
- tigerbeetle-0.16.18.dist-info/RECORD,,