gatun 0.2.0__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.
Files changed (47) hide show
  1. gatun/__init__.py +196 -0
  2. gatun/arena.py +568 -0
  3. gatun/async_client.py +1207 -0
  4. gatun/bridge.py +294 -0
  5. gatun/bridge_adapters.py +248 -0
  6. gatun/client.py +3782 -0
  7. gatun/config.py +137 -0
  8. gatun/generated/org/__init__.py +0 -0
  9. gatun/generated/org/gatun/__init__.py +0 -0
  10. gatun/generated/org/gatun/protocol/Action.py +30 -0
  11. gatun/generated/org/gatun/protocol/Argument.py +65 -0
  12. gatun/generated/org/gatun/protocol/ArrayVal.py +238 -0
  13. gatun/generated/org/gatun/protocol/ArrowBatchDescriptor.py +157 -0
  14. gatun/generated/org/gatun/protocol/BatchCommand.py +73 -0
  15. gatun/generated/org/gatun/protocol/BatchResponse.py +73 -0
  16. gatun/generated/org/gatun/protocol/BoolVal.py +42 -0
  17. gatun/generated/org/gatun/protocol/BufferDescriptor.py +52 -0
  18. gatun/generated/org/gatun/protocol/CallbackRef.py +52 -0
  19. gatun/generated/org/gatun/protocol/CallbackResult.py +85 -0
  20. gatun/generated/org/gatun/protocol/CharVal.py +42 -0
  21. gatun/generated/org/gatun/protocol/Command.py +183 -0
  22. gatun/generated/org/gatun/protocol/CreateObjectsRequest.py +63 -0
  23. gatun/generated/org/gatun/protocol/DoubleVal.py +42 -0
  24. gatun/generated/org/gatun/protocol/ElementType.py +14 -0
  25. gatun/generated/org/gatun/protocol/FieldNode.py +52 -0
  26. gatun/generated/org/gatun/protocol/GetFieldsRequest.py +58 -0
  27. gatun/generated/org/gatun/protocol/IntVal.py +42 -0
  28. gatun/generated/org/gatun/protocol/InvokeMethodsRequest.py +63 -0
  29. gatun/generated/org/gatun/protocol/ListVal.py +63 -0
  30. gatun/generated/org/gatun/protocol/MapEntry.py +60 -0
  31. gatun/generated/org/gatun/protocol/MapVal.py +63 -0
  32. gatun/generated/org/gatun/protocol/MethodCall.py +83 -0
  33. gatun/generated/org/gatun/protocol/NullVal.py +32 -0
  34. gatun/generated/org/gatun/protocol/ObjectRef.py +42 -0
  35. gatun/generated/org/gatun/protocol/ObjectSpec.py +73 -0
  36. gatun/generated/org/gatun/protocol/Response.py +174 -0
  37. gatun/generated/org/gatun/protocol/StringVal.py +42 -0
  38. gatun/generated/org/gatun/protocol/Value.py +17 -0
  39. gatun/generated/org/gatun/protocol/__init__.py +0 -0
  40. gatun/jars/gatun-server-all.jar +0 -0
  41. gatun/launcher.py +311 -0
  42. gatun/py.typed +0 -0
  43. gatun-0.2.0.dist-info/METADATA +14 -0
  44. gatun-0.2.0.dist-info/RECORD +47 -0
  45. gatun-0.2.0.dist-info/WHEEL +5 -0
  46. gatun-0.2.0.dist-info/licenses/LICENSE +201 -0
  47. gatun-0.2.0.dist-info/top_level.txt +1 -0
gatun/__init__.py ADDED
@@ -0,0 +1,196 @@
1
+ from typing import Optional
2
+
3
+ from gatun.client import (
4
+ GatunClient,
5
+ JavaObject,
6
+ JavaArray,
7
+ JVMView,
8
+ JavaClass,
9
+ java_import,
10
+ PROTOCOL_VERSION,
11
+ PayloadTooLargeError,
12
+ JavaException,
13
+ JavaSecurityException,
14
+ JavaIllegalArgumentException,
15
+ JavaNoSuchMethodException,
16
+ JavaNoSuchFieldException,
17
+ JavaClassNotFoundException,
18
+ JavaNullPointerException,
19
+ JavaIndexOutOfBoundsException,
20
+ JavaNumberFormatException,
21
+ JavaRuntimeException,
22
+ CancelledException,
23
+ ReentrancyError,
24
+ CallbackTimeoutError,
25
+ ProtocolDesyncError,
26
+ SocketTimeoutError,
27
+ DeadConnectionError,
28
+ StaleArenaError,
29
+ ArrowTableView,
30
+ BatchContext,
31
+ BatchResult,
32
+ TypeHint,
33
+ )
34
+ from gatun.async_client import (
35
+ AsyncGatunClient,
36
+ AsyncJavaObject,
37
+ AsyncJVMView,
38
+ AsyncJavaClass,
39
+ run_sync,
40
+ )
41
+ from gatun.config import GatunConfig, get_config, load_config, reset_config
42
+ from gatun.launcher import launch_gateway, GatunSession
43
+ from gatun.arena import PayloadArena, UnsupportedArrowTypeError
44
+
45
+ __all__ = [
46
+ # Sync client
47
+ "GatunClient",
48
+ "JavaObject",
49
+ "JavaArray",
50
+ "JVMView",
51
+ "JavaClass",
52
+ "java_import",
53
+ "BatchContext",
54
+ "BatchResult",
55
+ "TypeHint",
56
+ # Async client
57
+ "AsyncGatunClient",
58
+ "AsyncJavaObject",
59
+ "AsyncJVMView",
60
+ "AsyncJavaClass",
61
+ "run_sync",
62
+ # Utilities
63
+ "launch_gateway",
64
+ "GatunSession",
65
+ "connect",
66
+ "aconnect",
67
+ "PROTOCOL_VERSION",
68
+ "PayloadTooLargeError",
69
+ # Exceptions
70
+ "JavaException",
71
+ "JavaSecurityException",
72
+ "JavaIllegalArgumentException",
73
+ "JavaNoSuchMethodException",
74
+ "JavaNoSuchFieldException",
75
+ "JavaClassNotFoundException",
76
+ "JavaNullPointerException",
77
+ "JavaIndexOutOfBoundsException",
78
+ "JavaNumberFormatException",
79
+ "JavaRuntimeException",
80
+ "CancelledException",
81
+ "ReentrancyError",
82
+ "CallbackTimeoutError",
83
+ "ProtocolDesyncError",
84
+ "SocketTimeoutError",
85
+ "DeadConnectionError",
86
+ # Config
87
+ "GatunConfig",
88
+ "get_config",
89
+ "load_config",
90
+ "reset_config",
91
+ # Arrow zero-copy
92
+ "PayloadArena",
93
+ "UnsupportedArrowTypeError",
94
+ "StaleArenaError",
95
+ "ArrowTableView",
96
+ ]
97
+
98
+
99
+ def connect(
100
+ memory: Optional[str] = None,
101
+ socket_path: Optional[str] = None,
102
+ trace: bool = False,
103
+ log_level: Optional[str] = None,
104
+ debug: bool = False,
105
+ extra_jvm_flags: Optional[list[str]] = None,
106
+ ):
107
+ """Convenience: Launches server and returns connected client.
108
+
109
+ Args:
110
+ memory: Memory size (e.g., "512MB", "1GB"). Defaults to config value.
111
+ socket_path: Path to Unix socket. Defaults to config value or ~/gatun.sock.
112
+ trace: Enable trace mode for verbose method resolution logging.
113
+ log_level: Java logging level ("FINE", "FINER", "INFO", etc.).
114
+ debug: If True, Java server logs are printed to stderr in real-time.
115
+ extra_jvm_flags: Additional JVM flags to pass to the server (e.g., for resource limits).
116
+
117
+ Configuration can be set in pyproject.toml:
118
+ [tool.gatun]
119
+ memory = "64MB"
120
+ socket_path = "/tmp/gatun.sock"
121
+
122
+ Or via environment variables:
123
+ GATUN_MEMORY=64MB
124
+ GATUN_SOCKET_PATH=/tmp/gatun.sock
125
+ GATUN_TRACE=true
126
+ GATUN_LOG_LEVEL=FINE
127
+ GATUN_DEBUG=true
128
+ """
129
+ session = launch_gateway(
130
+ memory=memory,
131
+ socket_path=socket_path,
132
+ trace=trace,
133
+ log_level=log_level,
134
+ debug=debug,
135
+ extra_jvm_flags=extra_jvm_flags,
136
+ )
137
+
138
+ client = GatunClient(session.socket_path)
139
+ if not client.connect():
140
+ session.stop()
141
+ raise RuntimeError("Failed to connect to Gatun Server")
142
+
143
+ # Attach session to client so it doesn't get GC'd
144
+ client._server_session = session
145
+ return client
146
+
147
+
148
+ async def aconnect(
149
+ memory: Optional[str] = None,
150
+ socket_path: Optional[str] = None,
151
+ trace: bool = False,
152
+ log_level: Optional[str] = None,
153
+ debug: bool = False,
154
+ ) -> AsyncGatunClient:
155
+ """Async convenience: Launches server and returns connected async client.
156
+
157
+ Args:
158
+ memory: Memory size (e.g., "512MB", "1GB"). Defaults to config value.
159
+ socket_path: Path to Unix socket. Defaults to config value or ~/gatun.sock.
160
+ trace: Enable trace mode for verbose method resolution logging.
161
+ log_level: Java logging level ("FINE", "FINER", "INFO", etc.).
162
+ debug: If True, Java server logs are printed to stderr in real-time.
163
+
164
+ Example:
165
+ async with await aconnect() as client:
166
+ arr = await client.create_object("java.util.ArrayList")
167
+ await arr.add("hello")
168
+
169
+ Configuration can be set in pyproject.toml:
170
+ [tool.gatun]
171
+ memory = "64MB"
172
+ socket_path = "/tmp/gatun.sock"
173
+
174
+ Or via environment variables:
175
+ GATUN_MEMORY=64MB
176
+ GATUN_SOCKET_PATH=/tmp/gatun.sock
177
+ GATUN_TRACE=true
178
+ GATUN_LOG_LEVEL=FINE
179
+ GATUN_DEBUG=true
180
+ """
181
+ session = launch_gateway(
182
+ memory=memory,
183
+ socket_path=socket_path,
184
+ trace=trace,
185
+ log_level=log_level,
186
+ debug=debug,
187
+ )
188
+
189
+ client = AsyncGatunClient(session.socket_path)
190
+ if not await client.connect():
191
+ session.stop()
192
+ raise RuntimeError("Failed to connect to Gatun Server")
193
+
194
+ # Attach session to client so it doesn't get GC'd
195
+ client._server_session = session
196
+ return client