dex-python-sdk 1.32.0__tar.gz → 1.37.0__tar.gz
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.
- {dex_python_sdk-1.32.0 → dex_python_sdk-1.37.0}/PKG-INFO +212 -93
- {dex_python_sdk-1.32.0 → dex_python_sdk-1.37.0}/README.md +211 -92
- {dex_python_sdk-1.32.0 → dex_python_sdk-1.37.0}/dex/__init__.py +4 -1
- {dex_python_sdk-1.32.0 → dex_python_sdk-1.37.0}/dex/_credential_transport.py +42 -3
- dex_python_sdk-1.37.0/dex/_flow_service_tls.py +172 -0
- {dex_python_sdk-1.32.0 → dex_python_sdk-1.37.0}/dex/_invocation_context.py +8 -1
- {dex_python_sdk-1.32.0 → dex_python_sdk-1.37.0}/dex/_pull_worker.py +267 -178
- {dex_python_sdk-1.32.0 → dex_python_sdk-1.37.0}/dex/_server_protocol.py +40 -8
- {dex_python_sdk-1.32.0 → dex_python_sdk-1.37.0}/dex/async_client.py +178 -32
- {dex_python_sdk-1.32.0 → dex_python_sdk-1.37.0}/dex/async_worker.py +63 -22
- {dex_python_sdk-1.32.0 → dex_python_sdk-1.37.0}/dex/attribute.py +40 -10
- {dex_python_sdk-1.32.0 → dex_python_sdk-1.37.0}/dex/attribute_values.py +2 -0
- {dex_python_sdk-1.32.0 → dex_python_sdk-1.37.0}/dex/channel.py +11 -0
- {dex_python_sdk-1.32.0 → dex_python_sdk-1.37.0}/dex/client.py +196 -31
- {dex_python_sdk-1.32.0 → dex_python_sdk-1.37.0}/dex/client_options.py +8 -3
- {dex_python_sdk-1.32.0 → dex_python_sdk-1.37.0}/dex/codec.py +4 -0
- {dex_python_sdk-1.32.0 → dex_python_sdk-1.37.0}/dex/context.py +73 -4
- {dex_python_sdk-1.32.0 → dex_python_sdk-1.37.0}/dex/credential.py +2 -1
- dex_python_sdk-1.37.0/dex/dexpb/dex_pb2.py +443 -0
- {dex_python_sdk-1.32.0 → dex_python_sdk-1.37.0}/dex/dexpb/dex_pb2.pyi +80 -10
- {dex_python_sdk-1.32.0 → dex_python_sdk-1.37.0}/dex/dexpb/dex_pb2_grpc.py +16 -7
- {dex_python_sdk-1.32.0 → dex_python_sdk-1.37.0}/dex/flow.py +7 -0
- {dex_python_sdk-1.32.0 → dex_python_sdk-1.37.0}/dex/flow_options.py +27 -5
- dex_python_sdk-1.37.0/dex/flow_service_tls_options.py +81 -0
- {dex_python_sdk-1.32.0 → dex_python_sdk-1.37.0}/dex/pull_registration.py +28 -13
- {dex_python_sdk-1.32.0 → dex_python_sdk-1.37.0}/dex/runtime_errors.py +23 -0
- {dex_python_sdk-1.32.0 → dex_python_sdk-1.37.0}/dex/step.py +142 -17
- {dex_python_sdk-1.32.0 → dex_python_sdk-1.37.0}/dex/stream.py +23 -0
- {dex_python_sdk-1.32.0 → dex_python_sdk-1.37.0}/dex/subflow.py +36 -1
- {dex_python_sdk-1.32.0 → dex_python_sdk-1.37.0}/dex/timer.py +8 -1
- {dex_python_sdk-1.32.0 → dex_python_sdk-1.37.0}/dex/wait_options.py +4 -0
- {dex_python_sdk-1.32.0 → dex_python_sdk-1.37.0}/dex/worker.py +63 -22
- {dex_python_sdk-1.32.0 → dex_python_sdk-1.37.0}/dex/worker_options.py +43 -31
- {dex_python_sdk-1.32.0 → dex_python_sdk-1.37.0}/pyproject.toml +1 -1
- {dex_python_sdk-1.32.0 → dex_python_sdk-1.37.0}/sdk-rust/Cargo.lock +332 -5
- {dex_python_sdk-1.32.0 → dex_python_sdk-1.37.0}/sdk-rust/Cargo.toml +1 -1
- dex_python_sdk-1.32.0/dex/dexpb/dex_pb2.py +0 -433
- {dex_python_sdk-1.32.0 → dex_python_sdk-1.37.0}/LEGACY_NOTICES.md +0 -0
- {dex_python_sdk-1.32.0 → dex_python_sdk-1.37.0}/LICENSE +0 -0
- {dex_python_sdk-1.32.0 → dex_python_sdk-1.37.0}/dex/_async_value_hydrator.py +0 -0
- {dex_python_sdk-1.32.0 → dex_python_sdk-1.37.0}/dex/_async_worker_dispatcher.py +0 -0
- {dex_python_sdk-1.32.0 → dex_python_sdk-1.37.0}/dex/_attribute_reads.py +0 -0
- {dex_python_sdk-1.32.0 → dex_python_sdk-1.37.0}/dex/_grpc_errors.py +0 -0
- {dex_python_sdk-1.32.0 → dex_python_sdk-1.37.0}/dex/_native.pyi +0 -0
- {dex_python_sdk-1.32.0 → dex_python_sdk-1.37.0}/dex/_utils.py +0 -0
- {dex_python_sdk-1.32.0 → dex_python_sdk-1.37.0}/dex/_value_hydrator.py +0 -0
- {dex_python_sdk-1.32.0 → dex_python_sdk-1.37.0}/dex/_value_mapper.py +0 -0
- {dex_python_sdk-1.32.0 → dex_python_sdk-1.37.0}/dex/_worker_dispatcher.py +0 -0
- {dex_python_sdk-1.32.0 → dex_python_sdk-1.37.0}/dex/attribute_match.py +0 -0
- {dex_python_sdk-1.32.0 → dex_python_sdk-1.37.0}/dex/blob_cache.py +0 -0
- {dex_python_sdk-1.32.0 → dex_python_sdk-1.37.0}/dex/condition.py +0 -0
- {dex_python_sdk-1.32.0 → dex_python_sdk-1.37.0}/dex/dexpb/__init__.py +0 -0
- {dex_python_sdk-1.32.0 → dex_python_sdk-1.37.0}/dex/flow_config.py +0 -0
- {dex_python_sdk-1.32.0 → dex_python_sdk-1.37.0}/dex/flow_info.py +0 -0
- {dex_python_sdk-1.32.0 → dex_python_sdk-1.37.0}/dex/flow_result.py +0 -0
- {dex_python_sdk-1.32.0 → dex_python_sdk-1.37.0}/dex/py.typed +0 -0
- {dex_python_sdk-1.32.0 → dex_python_sdk-1.37.0}/dex/rpc_invoke_options.py +0 -0
- {dex_python_sdk-1.32.0 → dex_python_sdk-1.37.0}/dex/step_execution.py +0 -0
- {dex_python_sdk-1.32.0 → dex_python_sdk-1.37.0}/dex/wait.py +0 -0
- {dex_python_sdk-1.32.0 → dex_python_sdk-1.37.0}/sdk-rust/crates/dex-blob-cache/Cargo.toml +0 -0
- {dex_python_sdk-1.32.0 → dex_python_sdk-1.37.0}/sdk-rust/crates/dex-blob-cache/LICENSE +0 -0
- {dex_python_sdk-1.32.0 → dex_python_sdk-1.37.0}/sdk-rust/crates/dex-blob-cache/README.md +0 -0
- {dex_python_sdk-1.32.0 → dex_python_sdk-1.37.0}/sdk-rust/crates/dex-blob-cache/src/config.rs +0 -0
- {dex_python_sdk-1.32.0 → dex_python_sdk-1.37.0}/sdk-rust/crates/dex-blob-cache/src/entry.rs +0 -0
- {dex_python_sdk-1.32.0 → dex_python_sdk-1.37.0}/sdk-rust/crates/dex-blob-cache/src/error.rs +0 -0
- {dex_python_sdk-1.32.0 → dex_python_sdk-1.37.0}/sdk-rust/crates/dex-blob-cache/src/format.rs +0 -0
- {dex_python_sdk-1.32.0 → dex_python_sdk-1.37.0}/sdk-rust/crates/dex-blob-cache/src/lib.rs +0 -0
- {dex_python_sdk-1.32.0 → dex_python_sdk-1.37.0}/sdk-rust/crates/dex-blob-cache/src/policy.rs +0 -0
- {dex_python_sdk-1.32.0 → dex_python_sdk-1.37.0}/sdk-rust/crates/dex-blob-cache/src/store.rs +0 -0
- {dex_python_sdk-1.32.0 → dex_python_sdk-1.37.0}/sdk-rust/crates/dex-blob-cache/tests/blob_cache_integration.rs +0 -0
- {dex_python_sdk-1.32.0 → dex_python_sdk-1.37.0}/sdk-rust/crates/dex-blob-cache-python/Cargo.toml +0 -0
- {dex_python_sdk-1.32.0 → dex_python_sdk-1.37.0}/sdk-rust/crates/dex-blob-cache-python/LICENSE +0 -0
- {dex_python_sdk-1.32.0 → dex_python_sdk-1.37.0}/sdk-rust/crates/dex-blob-cache-python/README.md +0 -0
- {dex_python_sdk-1.32.0 → dex_python_sdk-1.37.0}/sdk-rust/crates/dex-blob-cache-python/src/lib.rs +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: dex-python-sdk
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.37.0
|
|
4
4
|
Requires-Dist: grpcio>=1.83.0
|
|
5
5
|
Requires-Dist: grpcio-status>=1.83.0
|
|
6
6
|
Requires-Dist: protobuf>=7.35.1
|
|
@@ -92,8 +92,104 @@ coroutine runs on the event loop. A loop-bound Future from another loop raises
|
|
|
92
92
|
TypeError; use `async def` to create it on the right loop. A blocked token keeps
|
|
93
93
|
one executor thread busy until it returns, and an unclosed Client or Worker may
|
|
94
94
|
retain up to four idle credential threads. Sync token lookup must return
|
|
95
|
-
promptly. By default, no authorization metadata is sent.
|
|
96
|
-
gRPC
|
|
95
|
+
promptly. By default, no authorization metadata is sent. The connection uses
|
|
96
|
+
plaintext gRPC unless `flow_service_tls` is set; protect the network path that
|
|
97
|
+
carries the token.
|
|
98
|
+
|
|
99
|
+
## TLS
|
|
100
|
+
|
|
101
|
+
Set `ClientOptions.flow_service_tls` and `WorkerOptions.flow_service_tls`
|
|
102
|
+
independently for a TLS endpoint, such as a TLS gateway in front of Dex.
|
|
103
|
+
Omitting the option keeps plaintext gRPC for local `dexcli dev` servers.
|
|
104
|
+
`FlowServiceTlsOptions()` enables TLS 1.2 or newer, verifies the certificate
|
|
105
|
+
and hostname, and requires HTTP/2 ALPN `h2`. Workers apply it to startup,
|
|
106
|
+
blob hydration, and pull task streams. The same settings work with `AsyncClient`
|
|
107
|
+
and `AsyncWorker`. File, API key, and custom bearer credentials compose with TLS
|
|
108
|
+
as call metadata.
|
|
109
|
+
|
|
110
|
+
With an application's registered `flow`, `registry`, and open `cache`:
|
|
111
|
+
|
|
112
|
+
```python
|
|
113
|
+
from concurrent.futures import ThreadPoolExecutor
|
|
114
|
+
from datetime import timedelta
|
|
115
|
+
from pathlib import Path
|
|
116
|
+
from uuid import uuid4
|
|
117
|
+
|
|
118
|
+
from dex import (
|
|
119
|
+
Client, ClientOptions, FileCredential, FlowServiceTlsOptions,
|
|
120
|
+
Worker, WorkerOptions,
|
|
121
|
+
)
|
|
122
|
+
|
|
123
|
+
flow_service_tls = FlowServiceTlsOptions(
|
|
124
|
+
additional_root_cas_pem=Path("/etc/dex/root-ca.pem").read_bytes(),
|
|
125
|
+
)
|
|
126
|
+
credential = FileCredential("/var/run/secrets/dex/token")
|
|
127
|
+
server_address = "dex.example.com:443"
|
|
128
|
+
with Worker(registry, cache, WorkerOptions(
|
|
129
|
+
server_address=server_address,
|
|
130
|
+
flow_service_tls=flow_service_tls,
|
|
131
|
+
credential=credential,
|
|
132
|
+
)) as worker, Client(registry, cache, ClientOptions(
|
|
133
|
+
server_address=server_address,
|
|
134
|
+
flow_service_tls=flow_service_tls,
|
|
135
|
+
credential=credential,
|
|
136
|
+
)) as client, ThreadPoolExecutor(max_workers=1) as executor:
|
|
137
|
+
started = executor.submit(worker.start)
|
|
138
|
+
try:
|
|
139
|
+
worker.wait_pull_registered(timeout=30)
|
|
140
|
+
flow_id = f"tls-{uuid4()}"
|
|
141
|
+
client.start_flow(flow, flow_id, input_value)
|
|
142
|
+
result = client.wait_for_flow(flow_id, timedelta(seconds=30))
|
|
143
|
+
finally:
|
|
144
|
+
worker.stop()
|
|
145
|
+
started.result(timeout=10)
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
- `additional_root_cas_pem` accepts PEM bytes or text. Omit it, or use an empty
|
|
149
|
+
value, for gRPC's default trust. A nonempty bundle must contain at least one
|
|
150
|
+
parsable certificate; malformed and non-certificate blocks are skipped when
|
|
151
|
+
another certificate parses. The trust is the gRPC default roots (grpcio's
|
|
152
|
+
bundled roots, or `GRPC_DEFAULT_SSL_ROOTS_FILE_PATH` when set) plus the added
|
|
153
|
+
roots. A configured gRPC root file replaces the bundled roots and takes
|
|
154
|
+
precedence over system roots. Adding roots fails when
|
|
155
|
+
`GRPC_USE_SYSTEM_ROOTS_OVER_LANGUAGE_CALLBACK` is true, unless a root file is
|
|
156
|
+
configured, regardless of `GRPC_NOT_USE_SYSTEM_SSL_ROOTS`.
|
|
157
|
+
True values are `true`, `t`, `yes`, `y`, and `1`, ignoring case. This guard
|
|
158
|
+
also applies to system roots selected with `GRPC_SYSTEM_SSL_ROOTS_DIR`.
|
|
159
|
+
To add roots in that configuration, disable
|
|
160
|
+
`GRPC_USE_SYSTEM_ROOTS_OVER_LANGUAGE_CALLBACK` and pass the full PEM bundle
|
|
161
|
+
as `additional_root_cas_pem`, or set `GRPC_DEFAULT_SSL_ROOTS_FILE_PATH` to the
|
|
162
|
+
full bundle. `SSL_CERT_FILE` and `SSL_CERT_DIR` do not affect this trust.
|
|
163
|
+
These sources are read at construction. An unreadable bundled root file, or an
|
|
164
|
+
unreadable or invalid configured gRPC root file, fails construction when adding
|
|
165
|
+
roots. Errors for configured files include the file path. To trust OS or
|
|
166
|
+
corporate CAs, pass their PEM bundle explicitly:
|
|
167
|
+
|
|
168
|
+
```python
|
|
169
|
+
tls = FlowServiceTlsOptions(
|
|
170
|
+
additional_root_cas_pem=Path("/etc/ssl/certs/ca-certificates.crt").read_bytes(),
|
|
171
|
+
)
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
Use the CA bundle path supplied by your OS or organization.
|
|
175
|
+
- `server_name` defaults to `None`, which verifies the address host and preserves
|
|
176
|
+
the host and port as HTTP/2 authority. Set a DNS name or IP without a port only
|
|
177
|
+
when the certificate name differs. It controls verification, SNI, and HTTP/2
|
|
178
|
+
authority; gateways must accept that authority without a port. Empty strings
|
|
179
|
+
are invalid. IP addresses require matching IP SANs and send no SNI. Prefer
|
|
180
|
+
a DNS name for IPv6 overrides because strict HTTP/2 servers reject an
|
|
181
|
+
unbracketed IPv6 authority.
|
|
182
|
+
- TLS targets accept `host:port`, `dns:///host:port`, and
|
|
183
|
+
`dns://authority/host:port`, including bracketed IPv6 hosts. Ports must be
|
|
184
|
+
unsigned decimal values from 1 through 65535. The DNS resolver authority
|
|
185
|
+
never becomes the certificate name. Other resolver schemes remain available
|
|
186
|
+
with plaintext only.
|
|
187
|
+
- Constructors raise `ValueError` for invalid addresses, server names, or PEM
|
|
188
|
+
bundles. Connections open on demand; certificate and handshake failures
|
|
189
|
+
surface on the first Client call as `UNAVAILABLE` or during Worker startup.
|
|
190
|
+
Servers offering only `http/1.1`, or no ALPN protocol, are rejected.
|
|
191
|
+
- This option does not configure the `ApiKeyCredential` token endpoint, which
|
|
192
|
+
uses HTTPS except on loopback.
|
|
97
193
|
|
|
98
194
|
## Workers
|
|
99
195
|
|
|
@@ -116,7 +212,7 @@ worker = Worker(
|
|
|
116
212
|
cache,
|
|
117
213
|
WorkerOptions(
|
|
118
214
|
server_address="dex.example:8801",
|
|
119
|
-
pull=PullWorkerOptions(max_concurrent_tasks=8
|
|
215
|
+
pull=PullWorkerOptions(max_concurrent_tasks=8),
|
|
120
216
|
),
|
|
121
217
|
)
|
|
122
218
|
worker_thread = threading.Thread(target=worker.start)
|
|
@@ -135,30 +231,26 @@ finally:
|
|
|
135
231
|
worker_thread.join()
|
|
136
232
|
```
|
|
137
233
|
|
|
138
|
-
The Worker
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
the server's dispatch wait (10 seconds by default, or the local Step attempt),
|
|
159
|
-
the Step follows its failure and retry policy; an RPC caller receives the named
|
|
160
|
-
error. This reassignment requires a Dex Server that supports it. Against older
|
|
161
|
-
Servers, the Worker returns the not-registered error as before.
|
|
234
|
+
The Worker opens exactly `max_concurrent_tasks` long-lived streams. Each stream
|
|
235
|
+
is one execution slot serving the sticky queue and every registered Flow type.
|
|
236
|
+
Flow type names must be unique within a Dex server. Concurrency defaults to the
|
|
237
|
+
CPU count. Start fails if the configured concurrency exceeds the Server's
|
|
238
|
+
reported `matching.maxConcurrentTasksCap`; zero means no limit was reported.
|
|
239
|
+
The Worker checks the limit on its first registration only. It then half-closes
|
|
240
|
+
its streams, drops any task they receive, and never reports readiness;
|
|
241
|
+
registration waiters raise the limit error. A lower limit reported on a later
|
|
242
|
+
reconnect is logged as a warning, and the Worker keeps running.
|
|
243
|
+
`idle_streams_per_queue` is deprecated, remains accepted, and has no effect.
|
|
244
|
+
Each slot executes every task it receives and never rejects a task for capacity.
|
|
245
|
+
Step heartbeats and stream writes use the same stream. Busy streams send a Pong
|
|
246
|
+
every 20 seconds until the final frame.
|
|
247
|
+
|
|
248
|
+
The Worker rejects an unregistered Step or RPC by name before its handler runs.
|
|
249
|
+
Dex tries another Worker without consuming a Step attempt, including when the
|
|
250
|
+
Flow was sticky to the rejecting Worker. If no connected Worker supports the
|
|
251
|
+
Step type, the Step stays queued until a Worker that supports it connects, the
|
|
252
|
+
Flow times out, or the Flow is stopped. An RPC caller receives the named error
|
|
253
|
+
after the Server's dispatch wait.
|
|
162
254
|
|
|
163
255
|
The generated `app_worker_id` uses the first nonempty `DEX_WORKER_INSTANCE`,
|
|
164
256
|
`POD_NAME`, `HOSTNAME`, or system hostname, plus eight random base32 characters.
|
|
@@ -166,41 +258,67 @@ An override must uniquely identify one Worker process and change after restart.
|
|
|
166
258
|
It must contain 1-63 ASCII letters, digits, dots, underscores, or hyphens and
|
|
167
259
|
must not equal a registered Flow type.
|
|
168
260
|
|
|
169
|
-
Pull streams reconnect after failures. A
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
`
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
261
|
+
Pull streams reconnect after failures. A broken stream cancels its handler;
|
|
262
|
+
its output is never sent on a replacement connection. Server-directed reconnect
|
|
263
|
+
lets an active task finish before sending its final output and half-closing.
|
|
264
|
+
If the Server has not confirmed that final output by EOF when the reconnect wait
|
|
265
|
+
of `stop_drain_timeout` ends, the stream gets up to 5 more seconds before it is
|
|
266
|
+
reset.
|
|
267
|
+
`start()` reports protocol and startup synchronization failures. Later transport
|
|
268
|
+
errors are logged and retried by default.
|
|
269
|
+
|
|
270
|
+
`stop()` starts no new tasks. Idle streams half-close immediately; busy streams
|
|
271
|
+
finish their handlers and send final output before half-closing. Task frames
|
|
272
|
+
arriving after stop begins are dropped without calling a handler. Streams keep
|
|
273
|
+
reading until server EOF or the remaining `stop_drain_timeout`, which defaults
|
|
274
|
+
to 30 seconds. On timeout, a busy stream is reset and its handler is canceled;
|
|
275
|
+
stop waits for the handler to return. Synchronous handlers should check
|
|
276
|
+
`Context.is_cancellation_requested()` during long operations. Any stream still
|
|
277
|
+
open at the deadline is reset, even one that is half-closed and still waiting
|
|
278
|
+
for server EOF, so stop returns once handlers return. Dex treats a task it sent
|
|
279
|
+
in that window as an attempt that may have run.
|
|
280
|
+
|
|
281
|
+
A stream whose final output was queued or written, but not yet confirmed by
|
|
282
|
+
server EOF or by the next assignment on that stream, is not reset at the drain
|
|
283
|
+
deadline. This holds even if its handler has finished or the stream has
|
|
284
|
+
half-closed, because a completed local write does not mean the Server read the
|
|
285
|
+
bytes. The stream gets up to 5 more seconds to send the output, half-close, and
|
|
286
|
+
receive server EOF, and is reset after that. `stop()` can therefore return up
|
|
287
|
+
to 5 seconds after the drain deadline.
|
|
288
|
+
|
|
289
|
+
A stream that fails locally, such as a read error, an undecodable or oversized
|
|
290
|
+
frame, a task frame with an invalid deadline or no request, a failed final
|
|
291
|
+
output write, or an unexpected server EOF, is always reset. It never
|
|
292
|
+
half-closes cleanly, because a clean half-close tells Dex the assigned task did
|
|
293
|
+
not run. A malformed task is never admitted and its handler never runs. Poll
|
|
294
|
+
streams accept only uncompressed responses.
|
|
295
|
+
|
|
296
|
+
After a slot sends a task's final output, Dex may assign its next task
|
|
297
|
+
immediately. The slot finishes local cleanup for the previous task first, then
|
|
298
|
+
starts the next one, unless stop has begun.
|
|
181
299
|
|
|
182
300
|
Call `worker.wait_pull_registered(timeout=30)` after starting a synchronous
|
|
183
301
|
Worker on another thread. For AsyncWorker, start it in another task and use
|
|
184
302
|
`await worker.wait_pull_registered(timeout=30)`. The timeout is in seconds;
|
|
185
|
-
`None` waits indefinitely. Each waits for
|
|
186
|
-
|
|
303
|
+
`None` waits indefinitely. Each waits for one `STEP_AND_RPC` stream and, when
|
|
304
|
+
RPC reservation is configured, one `RPC_ONLY` stream to register. Timeout raises `TimeoutError`;
|
|
187
305
|
async cancellation cancels only that wait. Startup failures reach waiters.
|
|
188
306
|
A permanent rejection before readiness raises `PullRegistrationError`, whose
|
|
189
|
-
`queue` and `error` identify the rejected
|
|
307
|
+
`queue` and `error` identify the rejected slot kind and original transport error.
|
|
190
308
|
Stopping before readiness raises `RuntimeError`.
|
|
191
309
|
|
|
192
310
|
Use `worker.pull_registration_state()` for subsequent readiness probes. Its
|
|
193
311
|
immutable `queues` expose `queue`, `has_registered_stream`, and
|
|
194
312
|
`last_permanent_error`. After initial registration, `is_ready` stays true across
|
|
195
|
-
transient failures, reconnects, and stop. It becomes false only when a
|
|
313
|
+
transient failures, reconnects, and stop. It becomes false only when a required slot kind
|
|
196
314
|
has a permanent error and no registered stream. Re-registration clears the
|
|
197
315
|
error. The startup wait keeps succeeding after initial registration, including
|
|
198
316
|
after stop. Multiple callers may wait independently before or after start.
|
|
199
317
|
|
|
200
318
|
`PullWorkerOptions(stop_on_permanent_stream_rejection=True)` makes the first
|
|
201
|
-
permanent rejection leaving a
|
|
319
|
+
permanent rejection leaving a slot kind without a registered stream drain within
|
|
202
320
|
`stop_drain_timeout`, then raise `PullRegistrationError` from `start()`. This
|
|
203
|
-
applies before and after readiness. Another registered stream for that
|
|
321
|
+
applies before and after readiness. Another registered stream for that slot kind
|
|
204
322
|
prevents shutdown. The default is False and retries indefinitely. Always call
|
|
205
323
|
`stop()` or `close()` afterward; both remain safe after `start()` returns.
|
|
206
324
|
|
|
@@ -215,32 +333,18 @@ long-running Steps; use a limit of at least two or set the reserve explicitly.
|
|
|
215
333
|
Flows must stay responsive because RPCs share Worker task capacity with Steps.
|
|
216
334
|
The value must be nonnegative and less than `max_concurrent_tasks` after its
|
|
217
335
|
CPU-count default is resolved; invalid values fail construction. RPC and Step
|
|
218
|
-
handlers count together.
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
InvokeWorkerRPC tasks can use the full limit.
|
|
336
|
+
handlers count together. Reserved slots register as `RPC_ONLY`; the remaining
|
|
337
|
+
slots register as `STEP_AND_RPC`. The Server assigns Steps only to the latter.
|
|
338
|
+
The Worker never declines a Step for capacity.
|
|
222
339
|
|
|
223
340
|
```python
|
|
224
341
|
pull = PullWorkerOptions(max_concurrent_tasks=8, reserved_rpc_tasks=2)
|
|
225
342
|
```
|
|
226
343
|
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
dispatch wait, then fall back according to their policy. A queue that declines
|
|
232
|
-
a Step for reserved RPC capacity keeps one additional idle stream until 30
|
|
233
|
-
seconds after its last decline. Other queues retain their configured count.
|
|
234
|
-
The Worker does not open the extra stream while all task slots are busy. Set
|
|
235
|
-
`idle_streams_per_queue` to at least two for heavy Step backlogs. A reserve decline
|
|
236
|
-
does not close a stream or change registration readiness.
|
|
237
|
-
|
|
238
|
-
Each reserve decline records the Flow type through the dex._pull_worker logger
|
|
239
|
-
at DEBUG level. Export the cumulative `pull_reserved_rpc_declines` Worker value
|
|
240
|
-
to distinguish reserve pressure from full-capacity rejections. The count excludes
|
|
241
|
-
full-capacity rejections and unknown names. It counts decline events, including
|
|
242
|
-
repeated declines of the same Step dispatch while Dex retries it. Read its rate
|
|
243
|
-
to assess reserve pressure. It never resets and remains available after shutdown.
|
|
344
|
+
The `pull_reserved_rpc_declines` counter is deprecated and always zero. It stays
|
|
345
|
+
available for source compatibility. Registration snapshot `queues` and error
|
|
346
|
+
`queue` fields retain their names but now hold slot kind labels, `STEP_AND_RPC`
|
|
347
|
+
and `RPC_ONLY`, rather than individual queue names.
|
|
244
348
|
|
|
245
349
|
## Flow state I/O
|
|
246
350
|
|
|
@@ -362,7 +466,7 @@ class TimeoutRecoveryStep(Step[None]):
|
|
|
362
466
|
return force_fail(failure.detail)
|
|
363
467
|
```
|
|
364
468
|
|
|
365
|
-
Python SDK for [Dex
|
|
469
|
+
Python SDK for [Dex durable workflows](https://github.com/superdurable/dex)
|
|
366
470
|
|
|
367
471
|
## New user contracts
|
|
368
472
|
|
|
@@ -471,12 +575,10 @@ option cannot be combined with an index or `sync_to_attribute_store`, and
|
|
|
471
575
|
the stored value. Handlers and `get_attributes` receive the value inline, and
|
|
472
576
|
the SDK never stores it in the local blob cache.
|
|
473
577
|
|
|
474
|
-
Hard-delete writes require a Server with an enabled blob store
|
|
475
|
-
protocol
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
result whose SubFlow start initializes one. A Client checks the Server protocol
|
|
479
|
-
once, before its first `start_flow` that initializes one.
|
|
578
|
+
Hard-delete writes require a Server with an enabled blob store. This SDK
|
|
579
|
+
requires protocol 4. Workers negotiate before startup and Clients negotiate
|
|
580
|
+
lazily before their first service request. Incompatible Servers fail with
|
|
581
|
+
`RuntimeError` before values are sent.
|
|
480
582
|
|
|
481
583
|
Each Flow keeps one stored copy per Attribute key, overwritten in place. A Step
|
|
482
584
|
or RPC attempt writes or deletes the stored value before its result commits, so
|
|
@@ -598,19 +700,18 @@ integer and string instances and routes to both by instance and StepRef.
|
|
|
598
700
|
`StepOptions.wait_for_method_timeout` and `execute_method_timeout` bound the
|
|
599
701
|
two handler calls. Timer and channel conditions determine how long a Step waits.
|
|
600
702
|
|
|
601
|
-
`wait_for_retry` and `execute_retry` limit one logical handler execution.
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
cumulative attempt.
|
|
703
|
+
`wait_for_retry` and `execute_retry` limit one logical handler execution.
|
|
704
|
+
Attempts use one-based numbers. The retry total duration starts when Dex first
|
|
705
|
+
hands the Step to a Worker. After an attempt fails, Dex checks that budget to
|
|
706
|
+
decide whether to schedule another retry; it does not end a running attempt.
|
|
606
707
|
|
|
607
708
|
The default Step durability is synchronous. A Flow configuration can select
|
|
608
709
|
asynchronous durability, and a Step method override has highest precedence. The
|
|
609
|
-
default retry total duration is four hours.
|
|
710
|
+
default retry total duration is four hours. Attempts default to a two-hour
|
|
610
711
|
method timeout and one-minute heartbeat timeout; an explicit heartbeat timeout must
|
|
611
712
|
meet the server minimum, which defaults to ten seconds. Asynchronous durability
|
|
612
|
-
|
|
613
|
-
|
|
713
|
+
gives lower latency and faster single Flows. Sustained throughput is about the
|
|
714
|
+
same as synchronous durability.
|
|
614
715
|
|
|
615
716
|
### Flow run start time
|
|
616
717
|
|
|
@@ -627,8 +728,7 @@ with `datetime.now(timezone.utc)` to measure the run's age. It matches
|
|
|
627
728
|
current `wait_for`, `execute`, or Flow timeout handler attempt. It is a
|
|
628
729
|
timezone-aware UTC `datetime` with microsecond precision, not a duration.
|
|
629
730
|
Subtract `datetime.now(timezone.utc)` and call `total_seconds()` to budget
|
|
630
|
-
remaining work after checking for `None`.
|
|
631
|
-
`RetryPolicy.total_duration` limits this deadline; each retry receives its own
|
|
731
|
+
remaining work after checking for `None`. Each retry receives its own
|
|
632
732
|
effective deadline. RPC handlers and tasks without a supplied deadline return
|
|
633
733
|
`None`.
|
|
634
734
|
|
|
@@ -993,15 +1093,34 @@ See [CONTRIBUTING.md](../CONTRIBUTING.md#releases-monorepo-tags) for monorepo ta
|
|
|
993
1093
|
|
|
994
1094
|
## Server protocol compatibility
|
|
995
1095
|
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1096
|
+
Workers call `GetServerInfo`, require protocol 4, synchronize Attribute indexes,
|
|
1097
|
+
and then open execution slot streams. The Python SDK protocol interval is
|
|
1098
|
+
`[4,4]`. Older Servers fail startup with this error, substituting the protocol
|
|
1099
|
+
range and Server version actually reported:
|
|
1100
|
+
|
|
1101
|
+
```text
|
|
1102
|
+
This SDK requires a Dex Server with protocol version 4 or later (server-zd newer than v0.1.16). The Server reports protocol versions <min>-<current> (server version <server_version>). Upgrade the Server before upgrading the SDK.
|
|
1103
|
+
```
|
|
1104
|
+
|
|
1105
|
+
A Server whose minimum protocol is newer than 4 fails with an error that asks
|
|
1106
|
+
you to upgrade the SDK. Missing information, invalid intervals, and RPC
|
|
1107
|
+
failures stop startup before polling.
|
|
1108
|
+
|
|
1109
|
+
Clients perform no network I/O during construction. Before the first request of
|
|
1110
|
+
any method, they negotiate protocol 4. Success and incompatibility are cached;
|
|
1111
|
+
later requests against an incompatible Server raise the same clear
|
|
1112
|
+
`RuntimeError`. If `GetServerInfo` itself fails, for example because the Server
|
|
1113
|
+
is unreachable, the request raises the usual `DexServiceError`, and the next
|
|
1114
|
+
call negotiates again. Negotiation counts against a request's timeout, including
|
|
1115
|
+
the `request_timeout` of durable waits.
|
|
1116
|
+
|
|
1117
|
+
`RetryPolicy.total_duration` counts from the first hand-out to a Worker. After
|
|
1118
|
+
an attempt fails, Dex checks it to decide whether to retry. It does not end a
|
|
1119
|
+
running attempt. Recovery handlers can inspect `RecoveryErrorInfo.attempt_progress`:
|
|
1120
|
+
`StepAttemptProgress.NOT_STARTED` guarantees no handler ran;
|
|
1121
|
+
`NOT_COMPLETED` means some attempt may have run but none completed;
|
|
1122
|
+
`UNSPECIFIED` covers older Servers or failures recorded before upgrade and must
|
|
1123
|
+
be treated like `NOT_COMPLETED`.
|
|
1005
1124
|
|
|
1006
1125
|
The diagnostic SDK version comes from Python distribution metadata for
|
|
1007
1126
|
`dex-python-sdk` and falls back to `dev` when the distribution is unavailable.
|