requence 0.8.1.dev64__tar.gz → 0.8.1.dev67__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.
- requence-0.8.1.dev67/PKG-INFO +137 -0
- requence-0.8.1.dev67/README.md +125 -0
- {requence-0.8.1.dev64 → requence-0.8.1.dev67}/pyproject.toml +1 -1
- {requence-0.8.1.dev64 → requence-0.8.1.dev67}/requence/context.py +13 -1
- {requence-0.8.1.dev64 → requence-0.8.1.dev67}/requence/internal_types.py +11 -0
- {requence-0.8.1.dev64 → requence-0.8.1.dev67}/requence/service/__init__.py +62 -1
- requence-0.8.1.dev67/requence/store.py +354 -0
- requence-0.8.1.dev67/requence.egg-info/PKG-INFO +137 -0
- {requence-0.8.1.dev64 → requence-0.8.1.dev67}/requence.egg-info/SOURCES.txt +2 -0
- requence-0.8.1.dev67/tests/test_store_parity.py +377 -0
- requence-0.8.1.dev64/PKG-INFO +0 -972
- requence-0.8.1.dev64/README.md +0 -960
- requence-0.8.1.dev64/requence.egg-info/PKG-INFO +0 -972
- {requence-0.8.1.dev64 → requence-0.8.1.dev67}/MANIFEST.in +0 -0
- {requence-0.8.1.dev64 → requence-0.8.1.dev67}/requence/__init__.py +0 -0
- {requence-0.8.1.dev64 → requence-0.8.1.dev67}/requence/callbacks/__init__.py +0 -0
- {requence-0.8.1.dev64 → requence-0.8.1.dev67}/requence/callbacks/context.py +0 -0
- {requence-0.8.1.dev64 → requence-0.8.1.dev67}/requence/callbacks/handler.py +0 -0
- {requence-0.8.1.dev64 → requence-0.8.1.dev67}/requence/client_properties.py +0 -0
- {requence-0.8.1.dev64 → requence-0.8.1.dev67}/requence/exceptions.py +0 -0
- {requence-0.8.1.dev64 → requence-0.8.1.dev67}/requence/files/__init__.py +0 -0
- {requence-0.8.1.dev64 → requence-0.8.1.dev67}/requence/files/errors.py +0 -0
- {requence-0.8.1.dev64 → requence-0.8.1.dev67}/requence/files/handlers/__init__.py +0 -0
- {requence-0.8.1.dev64 → requence-0.8.1.dev67}/requence/files/handlers/claim_check_handler.py +0 -0
- {requence-0.8.1.dev64 → requence-0.8.1.dev67}/requence/files/handlers/context.py +0 -0
- {requence-0.8.1.dev64 → requence-0.8.1.dev67}/requence/files/handlers/file_handler.py +0 -0
- {requence-0.8.1.dev64 → requence-0.8.1.dev67}/requence/files/handlers/stream_handler.py +0 -0
- {requence-0.8.1.dev64 → requence-0.8.1.dev67}/requence/files/pending_uploads.py +0 -0
- {requence-0.8.1.dev64 → requence-0.8.1.dev67}/requence/files/requence_file.py +0 -0
- {requence-0.8.1.dev64 → requence-0.8.1.dev67}/requence/files/requence_stream.py +0 -0
- {requence-0.8.1.dev64 → requence-0.8.1.dev67}/requence/files/sanitize_log_data.py +0 -0
- {requence-0.8.1.dev64 → requence-0.8.1.dev67}/requence/files/stream_framing.py +0 -0
- {requence-0.8.1.dev64 → requence-0.8.1.dev67}/requence/files/transport.py +0 -0
- {requence-0.8.1.dev64 → requence-0.8.1.dev67}/requence/logger.py +0 -0
- {requence-0.8.1.dev64 → requence-0.8.1.dev67}/requence/obfuscase.py +0 -0
- {requence-0.8.1.dev64 → requence-0.8.1.dev67}/requence/py.typed +0 -0
- {requence-0.8.1.dev64 → requence-0.8.1.dev67}/requence/reachable.py +0 -0
- {requence-0.8.1.dev64 → requence-0.8.1.dev67}/requence/requence_callback.py +0 -0
- {requence-0.8.1.dev64 → requence-0.8.1.dev67}/requence/requence_file.py +0 -0
- {requence-0.8.1.dev64 → requence-0.8.1.dev67}/requence/requence_stream.py +0 -0
- {requence-0.8.1.dev64 → requence-0.8.1.dev67}/requence/service/boundary.py +0 -0
- {requence-0.8.1.dev64 → requence-0.8.1.dev67}/requence/service/callback_growth.py +0 -0
- {requence-0.8.1.dev64 → requence-0.8.1.dev67}/requence/service/cli.py +0 -0
- {requence-0.8.1.dev64 → requence-0.8.1.dev67}/requence/service/durable_callback.py +0 -0
- {requence-0.8.1.dev64 → requence-0.8.1.dev67}/requence/service/surface_handler.py +0 -0
- {requence-0.8.1.dev64 → requence-0.8.1.dev67}/requence/service/transformer.py +0 -0
- {requence-0.8.1.dev64 → requence-0.8.1.dev67}/requence/service/types.py +0 -0
- {requence-0.8.1.dev64 → requence-0.8.1.dev67}/requence/service/ui.py +0 -0
- {requence-0.8.1.dev64 → requence-0.8.1.dev67}/requence/service/ui_watch.py +0 -0
- {requence-0.8.1.dev64 → requence-0.8.1.dev67}/requence/task/__init__.py +0 -0
- {requence-0.8.1.dev64 → requence-0.8.1.dev67}/requence/task/abort_task.py +0 -0
- {requence-0.8.1.dev64 → requence-0.8.1.dev67}/requence/task/ack_task.py +0 -0
- {requence-0.8.1.dev64 → requence-0.8.1.dev67}/requence/task/cli.py +0 -0
- {requence-0.8.1.dev64 → requence-0.8.1.dev67}/requence/task/get_task.py +0 -0
- {requence-0.8.1.dev64 → requence-0.8.1.dev67}/requence/task/ingress.py +0 -0
- {requence-0.8.1.dev64 → requence-0.8.1.dev67}/requence/task/protect_task.py +0 -0
- {requence-0.8.1.dev64 → requence-0.8.1.dev67}/requence/task/task.py +0 -0
- {requence-0.8.1.dev64 → requence-0.8.1.dev67}/requence/task/task_watcher.py +0 -0
- {requence-0.8.1.dev64 → requence-0.8.1.dev67}/requence/task/types.py +0 -0
- {requence-0.8.1.dev64 → requence-0.8.1.dev67}/requence/task/updates.py +0 -0
- {requence-0.8.1.dev64 → requence-0.8.1.dev67}/requence/task/utils.py +0 -0
- {requence-0.8.1.dev64 → requence-0.8.1.dev67}/requence/transformer/__init__.py +0 -0
- {requence-0.8.1.dev64 → requence-0.8.1.dev67}/requence/transformer/context.py +0 -0
- {requence-0.8.1.dev64 → requence-0.8.1.dev67}/requence/transformer/errors.py +0 -0
- {requence-0.8.1.dev64 → requence-0.8.1.dev67}/requence/transformer/guards.py +0 -0
- {requence-0.8.1.dev64 → requence-0.8.1.dev67}/requence/transformer/message_handler.py +0 -0
- {requence-0.8.1.dev64 → requence-0.8.1.dev67}/requence/transformer/transform.py +0 -0
- {requence-0.8.1.dev64 → requence-0.8.1.dev67}/requence/transformer/value_handler.py +0 -0
- {requence-0.8.1.dev64 → requence-0.8.1.dev67}/requence/transformer/walk.py +0 -0
- {requence-0.8.1.dev64 → requence-0.8.1.dev67}/requence/utils.py +0 -0
- {requence-0.8.1.dev64 → requence-0.8.1.dev67}/requence/wire.py +0 -0
- {requence-0.8.1.dev64 → requence-0.8.1.dev67}/requence/wire_codec.py +0 -0
- {requence-0.8.1.dev64 → requence-0.8.1.dev67}/requence.egg-info/dependency_links.txt +0 -0
- {requence-0.8.1.dev64 → requence-0.8.1.dev67}/requence.egg-info/entry_points.txt +0 -0
- {requence-0.8.1.dev64 → requence-0.8.1.dev67}/requence.egg-info/requires.txt +0 -0
- {requence-0.8.1.dev64 → requence-0.8.1.dev67}/requence.egg-info/top_level.txt +0 -0
- {requence-0.8.1.dev64 → requence-0.8.1.dev67}/setup.cfg +0 -0
- {requence-0.8.1.dev64 → requence-0.8.1.dev67}/tests/test_client_properties.py +0 -0
- {requence-0.8.1.dev64 → requence-0.8.1.dev67}/tests/test_logger.py +0 -0
- {requence-0.8.1.dev64 → requence-0.8.1.dev67}/tests/test_wire.py +0 -0
- {requence-0.8.1.dev64 → requence-0.8.1.dev67}/tests/test_wire_codec.py +0 -0
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: requence
|
|
3
|
+
Version: 0.8.1.dev67
|
|
4
|
+
Summary: Requence Service
|
|
5
|
+
Author: Torsten Blindert
|
|
6
|
+
Requires-Python: >=3.12
|
|
7
|
+
Description-Content-Type: text/markdown
|
|
8
|
+
Requires-Dist: pika>=1.3.2
|
|
9
|
+
Requires-Dist: requests>=2.32.2
|
|
10
|
+
Requires-Dist: sseclient-py>=1.8.0
|
|
11
|
+
Requires-Dist: msgpack>=1.0.5
|
|
12
|
+
|
|
13
|
+
# requence
|
|
14
|
+
|
|
15
|
+
The official Python SDK for the Requence platform. It covers both halves of the integration:
|
|
16
|
+
|
|
17
|
+
- **`requence.service`** — connect a Python service to Requence and process messages
|
|
18
|
+
- **`requence.task`** — start and monitor Requence tasks programmatically
|
|
19
|
+
|
|
20
|
+
> **This README is a getting-started guide.** The reference for both halves lives at
|
|
21
|
+
> **<https://docs.requence.cloud>** — every page has a **Python** tab, including the places
|
|
22
|
+
> where Python's answer differs from TypeScript's.
|
|
23
|
+
|
|
24
|
+
## Requirements
|
|
25
|
+
|
|
26
|
+
Python 3.12 or later.
|
|
27
|
+
|
|
28
|
+
## Installation
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
pip install requence
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Authentication
|
|
35
|
+
|
|
36
|
+
Copy a service's access token from the **Services** list view in the Requence UI
|
|
37
|
+
(**Copy credentials**). A task needs a personal or scoped access token instead.
|
|
38
|
+
|
|
39
|
+
Tokens are resolved in this order:
|
|
40
|
+
|
|
41
|
+
1. `access_token` passed to `Service()` / `Task()`
|
|
42
|
+
2. `REQUENCE_SERVICE_ACCESS_TOKEN` / `REQUENCE_TASK_ACCESS_TOKEN`, then `REQUENCE_ACCESS_TOKEN`
|
|
43
|
+
3. `requence.service_access_token` / `requence.task_access_token`, then `requence.access_token`
|
|
44
|
+
in `pyproject.toml`
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
REQUENCE_SERVICE_ACCESS_TOKEN=your-token python main.py
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Your first service
|
|
51
|
+
|
|
52
|
+
Create the service in the Requence UI first — its input schema, configuration schema and
|
|
53
|
+
outputs. Then implement the version:
|
|
54
|
+
|
|
55
|
+
```python
|
|
56
|
+
from requence.service import Service
|
|
57
|
+
|
|
58
|
+
def handler(ctx):
|
|
59
|
+
return {"message": f"Hello, {ctx.input['name']}!"}
|
|
60
|
+
|
|
61
|
+
Service("1.0.0", handler)
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
> **`Service(...)` never returns.** It consumes on the calling thread, so there is no instance
|
|
65
|
+
> to call `act()` or `close()` on. Use `Service.start(...)` when you need either — it returns
|
|
66
|
+
> the instance once connected, on a daemon consume thread. See
|
|
67
|
+
> [Starting & Stopping][lifecycle].
|
|
68
|
+
|
|
69
|
+
Generate type stubs for `ctx.input`, `ctx.configuration` and `ctx.to_output()` from the schemas
|
|
70
|
+
you defined in the UI:
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
requence-service generate-types
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## Your first task
|
|
77
|
+
|
|
78
|
+
```python
|
|
79
|
+
from requence.task import Task
|
|
80
|
+
|
|
81
|
+
task = Task(task_template="my-template", input={"name": "World"})
|
|
82
|
+
result = task.sync.result # blocks until the task completes
|
|
83
|
+
|
|
84
|
+
print(result["result"])
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
`task.sync` holds the blocking accessors; `await task.result` and `async for update in
|
|
88
|
+
task.updates` are the async equivalents.
|
|
89
|
+
|
|
90
|
+
## Where to read next
|
|
91
|
+
|
|
92
|
+
### Writing a service
|
|
93
|
+
|
|
94
|
+
| Topic | Page |
|
|
95
|
+
| ----------------------------------------------------------------------- | ------------------------------------------------- |
|
|
96
|
+
| The full walkthrough | [Getting Started][started] |
|
|
97
|
+
| `ctx.input`, `ctx.debug`, `retry`, `abort`, `skip`, `to_output`, `defer` | [Context API][context] |
|
|
98
|
+
| `prefetch`, `ssl_context`, TLS via environment | [Service Options][options] |
|
|
99
|
+
| `Service(...)` vs `Service.start(...)`, `close()` | [Starting & Stopping][lifecycle] |
|
|
100
|
+
| Generator handlers and `ctx.terminated` | [Continuous Mode][continuous] |
|
|
101
|
+
| `ctx.store` — what a node remembers past this message | [The Store][store] · [`ctx.store`][context-store] |
|
|
102
|
+
| `create_durable_callback`, `.for_(…)` | [Callbacks][callbacks] |
|
|
103
|
+
| `create_ui`, `ctx.render`, handler props | [Surfaces][surfaces] |
|
|
104
|
+
| `ctx.defer()` → `service.act()` | [Deferred Delivery][deferred] |
|
|
105
|
+
| Running locally against real tasks | [Dev Overlay][overlay] |
|
|
106
|
+
| `requence-service generate-types` | [Typing / CLI][typing] |
|
|
107
|
+
|
|
108
|
+
### Starting tasks
|
|
109
|
+
|
|
110
|
+
| Topic | Page |
|
|
111
|
+
| --------------------------------------------------------- | ------------------------------- |
|
|
112
|
+
| Options, `task.sync`, abort, protect, `require_ack` | [Starting Tasks][starting] |
|
|
113
|
+
| Sync and async iteration, the update types | [Streaming Updates][streaming] |
|
|
114
|
+
| `TaskWatcher` across every task | [Watching Tasks][watching] |
|
|
115
|
+
| `get_task` | [Fetching & Recreating][fetch] |
|
|
116
|
+
| `requence-task generate-types` | [CLI][cli] |
|
|
117
|
+
|
|
118
|
+
`test/demo-service/surface_demo.py` and `test/demo-python/` in the Requence repository are
|
|
119
|
+
runnable examples.
|
|
120
|
+
|
|
121
|
+
[started]: https://docs.requence.cloud/implementation/getting-started/
|
|
122
|
+
[context]: https://docs.requence.cloud/implementation/context-api/
|
|
123
|
+
[context-store]: https://docs.requence.cloud/implementation/context-api/#ctxstoreprivatekey-binding--ctxstoresharedkey-binding
|
|
124
|
+
[options]: https://docs.requence.cloud/implementation/advanced/service-options/
|
|
125
|
+
[lifecycle]: https://docs.requence.cloud/implementation/advanced/
|
|
126
|
+
[continuous]: https://docs.requence.cloud/planning/continuous-mode/
|
|
127
|
+
[store]: https://docs.requence.cloud/planning/store/
|
|
128
|
+
[callbacks]: https://docs.requence.cloud/implementation/callbacks/
|
|
129
|
+
[surfaces]: https://docs.requence.cloud/implementation/surfaces/
|
|
130
|
+
[deferred]: https://docs.requence.cloud/implementation/advanced/deferred-delivery/
|
|
131
|
+
[overlay]: https://docs.requence.cloud/implementation/advanced/dev-overlay/
|
|
132
|
+
[typing]: https://docs.requence.cloud/implementation/typing-cli/
|
|
133
|
+
[starting]: https://docs.requence.cloud/execution/starting-tasks/
|
|
134
|
+
[streaming]: https://docs.requence.cloud/execution/streaming/
|
|
135
|
+
[watching]: https://docs.requence.cloud/execution/watching-tasks/
|
|
136
|
+
[fetch]: https://docs.requence.cloud/execution/managing-tasks/
|
|
137
|
+
[cli]: https://docs.requence.cloud/execution/cli/
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
# requence
|
|
2
|
+
|
|
3
|
+
The official Python SDK for the Requence platform. It covers both halves of the integration:
|
|
4
|
+
|
|
5
|
+
- **`requence.service`** — connect a Python service to Requence and process messages
|
|
6
|
+
- **`requence.task`** — start and monitor Requence tasks programmatically
|
|
7
|
+
|
|
8
|
+
> **This README is a getting-started guide.** The reference for both halves lives at
|
|
9
|
+
> **<https://docs.requence.cloud>** — every page has a **Python** tab, including the places
|
|
10
|
+
> where Python's answer differs from TypeScript's.
|
|
11
|
+
|
|
12
|
+
## Requirements
|
|
13
|
+
|
|
14
|
+
Python 3.12 or later.
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
pip install requence
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Authentication
|
|
23
|
+
|
|
24
|
+
Copy a service's access token from the **Services** list view in the Requence UI
|
|
25
|
+
(**Copy credentials**). A task needs a personal or scoped access token instead.
|
|
26
|
+
|
|
27
|
+
Tokens are resolved in this order:
|
|
28
|
+
|
|
29
|
+
1. `access_token` passed to `Service()` / `Task()`
|
|
30
|
+
2. `REQUENCE_SERVICE_ACCESS_TOKEN` / `REQUENCE_TASK_ACCESS_TOKEN`, then `REQUENCE_ACCESS_TOKEN`
|
|
31
|
+
3. `requence.service_access_token` / `requence.task_access_token`, then `requence.access_token`
|
|
32
|
+
in `pyproject.toml`
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
REQUENCE_SERVICE_ACCESS_TOKEN=your-token python main.py
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Your first service
|
|
39
|
+
|
|
40
|
+
Create the service in the Requence UI first — its input schema, configuration schema and
|
|
41
|
+
outputs. Then implement the version:
|
|
42
|
+
|
|
43
|
+
```python
|
|
44
|
+
from requence.service import Service
|
|
45
|
+
|
|
46
|
+
def handler(ctx):
|
|
47
|
+
return {"message": f"Hello, {ctx.input['name']}!"}
|
|
48
|
+
|
|
49
|
+
Service("1.0.0", handler)
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
> **`Service(...)` never returns.** It consumes on the calling thread, so there is no instance
|
|
53
|
+
> to call `act()` or `close()` on. Use `Service.start(...)` when you need either — it returns
|
|
54
|
+
> the instance once connected, on a daemon consume thread. See
|
|
55
|
+
> [Starting & Stopping][lifecycle].
|
|
56
|
+
|
|
57
|
+
Generate type stubs for `ctx.input`, `ctx.configuration` and `ctx.to_output()` from the schemas
|
|
58
|
+
you defined in the UI:
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
requence-service generate-types
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## Your first task
|
|
65
|
+
|
|
66
|
+
```python
|
|
67
|
+
from requence.task import Task
|
|
68
|
+
|
|
69
|
+
task = Task(task_template="my-template", input={"name": "World"})
|
|
70
|
+
result = task.sync.result # blocks until the task completes
|
|
71
|
+
|
|
72
|
+
print(result["result"])
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
`task.sync` holds the blocking accessors; `await task.result` and `async for update in
|
|
76
|
+
task.updates` are the async equivalents.
|
|
77
|
+
|
|
78
|
+
## Where to read next
|
|
79
|
+
|
|
80
|
+
### Writing a service
|
|
81
|
+
|
|
82
|
+
| Topic | Page |
|
|
83
|
+
| ----------------------------------------------------------------------- | ------------------------------------------------- |
|
|
84
|
+
| The full walkthrough | [Getting Started][started] |
|
|
85
|
+
| `ctx.input`, `ctx.debug`, `retry`, `abort`, `skip`, `to_output`, `defer` | [Context API][context] |
|
|
86
|
+
| `prefetch`, `ssl_context`, TLS via environment | [Service Options][options] |
|
|
87
|
+
| `Service(...)` vs `Service.start(...)`, `close()` | [Starting & Stopping][lifecycle] |
|
|
88
|
+
| Generator handlers and `ctx.terminated` | [Continuous Mode][continuous] |
|
|
89
|
+
| `ctx.store` — what a node remembers past this message | [The Store][store] · [`ctx.store`][context-store] |
|
|
90
|
+
| `create_durable_callback`, `.for_(…)` | [Callbacks][callbacks] |
|
|
91
|
+
| `create_ui`, `ctx.render`, handler props | [Surfaces][surfaces] |
|
|
92
|
+
| `ctx.defer()` → `service.act()` | [Deferred Delivery][deferred] |
|
|
93
|
+
| Running locally against real tasks | [Dev Overlay][overlay] |
|
|
94
|
+
| `requence-service generate-types` | [Typing / CLI][typing] |
|
|
95
|
+
|
|
96
|
+
### Starting tasks
|
|
97
|
+
|
|
98
|
+
| Topic | Page |
|
|
99
|
+
| --------------------------------------------------------- | ------------------------------- |
|
|
100
|
+
| Options, `task.sync`, abort, protect, `require_ack` | [Starting Tasks][starting] |
|
|
101
|
+
| Sync and async iteration, the update types | [Streaming Updates][streaming] |
|
|
102
|
+
| `TaskWatcher` across every task | [Watching Tasks][watching] |
|
|
103
|
+
| `get_task` | [Fetching & Recreating][fetch] |
|
|
104
|
+
| `requence-task generate-types` | [CLI][cli] |
|
|
105
|
+
|
|
106
|
+
`test/demo-service/surface_demo.py` and `test/demo-python/` in the Requence repository are
|
|
107
|
+
runnable examples.
|
|
108
|
+
|
|
109
|
+
[started]: https://docs.requence.cloud/implementation/getting-started/
|
|
110
|
+
[context]: https://docs.requence.cloud/implementation/context-api/
|
|
111
|
+
[context-store]: https://docs.requence.cloud/implementation/context-api/#ctxstoreprivatekey-binding--ctxstoresharedkey-binding
|
|
112
|
+
[options]: https://docs.requence.cloud/implementation/advanced/service-options/
|
|
113
|
+
[lifecycle]: https://docs.requence.cloud/implementation/advanced/
|
|
114
|
+
[continuous]: https://docs.requence.cloud/planning/continuous-mode/
|
|
115
|
+
[store]: https://docs.requence.cloud/planning/store/
|
|
116
|
+
[callbacks]: https://docs.requence.cloud/implementation/callbacks/
|
|
117
|
+
[surfaces]: https://docs.requence.cloud/implementation/surfaces/
|
|
118
|
+
[deferred]: https://docs.requence.cloud/implementation/advanced/deferred-delivery/
|
|
119
|
+
[overlay]: https://docs.requence.cloud/implementation/advanced/dev-overlay/
|
|
120
|
+
[typing]: https://docs.requence.cloud/implementation/typing-cli/
|
|
121
|
+
[starting]: https://docs.requence.cloud/execution/starting-tasks/
|
|
122
|
+
[streaming]: https://docs.requence.cloud/execution/streaming/
|
|
123
|
+
[watching]: https://docs.requence.cloud/execution/watching-tasks/
|
|
124
|
+
[fetch]: https://docs.requence.cloud/execution/managing-tasks/
|
|
125
|
+
[cli]: https://docs.requence.cloud/execution/cli/
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "requence"
|
|
7
|
-
version = "0.8.1.
|
|
7
|
+
version = "0.8.1.dev67"
|
|
8
8
|
description = "Requence Service"
|
|
9
9
|
readme = { file = "README.md", content-type = "text/markdown" }
|
|
10
10
|
authors = [{ name = "Torsten Blindert" }]
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
from typing import TYPE_CHECKING, Any, Optional, Callable, cast
|
|
2
2
|
from .exceptions import RetryException, AbortException, SkipException
|
|
3
|
+
from .store import Store
|
|
3
4
|
from .utils import OutputValue
|
|
4
5
|
from .wire import DEFAULT_SURFACE_ID
|
|
5
6
|
import threading
|
|
@@ -41,7 +42,8 @@ class Context[I, C]:
|
|
|
41
42
|
on_log: Callable[[str, Any], None],
|
|
42
43
|
on_defer: Callable[[Optional[str]], str],
|
|
43
44
|
terminated: threading.Event,
|
|
44
|
-
on_render: Optional[Callable[["RequenceUI[Any]", Any, str], None]] = None
|
|
45
|
+
on_render: Optional[Callable[["RequenceUI[Any]", Any, str], None]] = None,
|
|
46
|
+
store: Optional[Store] = None
|
|
45
47
|
):
|
|
46
48
|
|
|
47
49
|
self.task_id = task_id
|
|
@@ -51,6 +53,16 @@ class Context[I, C]:
|
|
|
51
53
|
self.__on_defer = on_defer
|
|
52
54
|
self.__on_render = on_render
|
|
53
55
|
self.debug = Debug(on_log)
|
|
56
|
+
# What this node remembers past the end of this message, and past the
|
|
57
|
+
# end of this task (#211). Always present, so `context.store` is never
|
|
58
|
+
# the thing that is missing — a dispatch carrying no capability says so
|
|
59
|
+
# when a slot is read or written, not here.
|
|
60
|
+
#
|
|
61
|
+
# `store=None` only reaches a context built outside a dispatch (tests);
|
|
62
|
+
# such a store has nothing to address and says exactly that.
|
|
63
|
+
self.store = store if store is not None else Store(
|
|
64
|
+
url=None, signature=None, task_id=task_id, node_id=None
|
|
65
|
+
)
|
|
54
66
|
|
|
55
67
|
def retry(self, delay: Optional[int] = None):
|
|
56
68
|
raise RetryException(delay)
|
|
@@ -21,6 +21,12 @@ class TaskOptions(TypedDict, total=False):
|
|
|
21
21
|
# URLs: claim-check offload threshold and RequenceFile/RequenceStream cap.
|
|
22
22
|
maxPayloadSize: Optional[int]
|
|
23
23
|
maxFileSize: Optional[int]
|
|
24
|
+
# The store capability (#211), copied onto every dispatch by the operator,
|
|
25
|
+
# which reads neither field. The URL is TOLD rather than derived — unlike a
|
|
26
|
+
# file reference, a store call carries no URL of its own — and it is the
|
|
27
|
+
# PUBLIC one, because an off-overlay service is a supported deployment.
|
|
28
|
+
storeUrl: Optional[str]
|
|
29
|
+
storeSignature: Optional[str]
|
|
24
30
|
|
|
25
31
|
class Payload(TypedDict, total=True):
|
|
26
32
|
input: Any
|
|
@@ -30,6 +36,11 @@ class Payload(TypedDict, total=True):
|
|
|
30
36
|
# dispatch minted before it existed carries none, and that message simply
|
|
31
37
|
# cannot emit one.
|
|
32
38
|
nodeId: NotRequired[str]
|
|
39
|
+
# Set only when this dispatch is a configuration-function evaluation (#224).
|
|
40
|
+
# `nodeId` is then the HOST node's, and a `private` store slot addresses that
|
|
41
|
+
# node's configuration box rather than the host service's own. Not spelled
|
|
42
|
+
# `configuration`: that key above is this envelope's configuration VALUE.
|
|
43
|
+
configurationEval: NotRequired[bool]
|
|
33
44
|
options: TaskOptions
|
|
34
45
|
|
|
35
46
|
class ActorApi(TypedDict):
|
|
@@ -9,6 +9,7 @@ from ..client_properties import (
|
|
|
9
9
|
unsupported_capabilities,
|
|
10
10
|
)
|
|
11
11
|
from ..context import Context
|
|
12
|
+
from ..store import Store
|
|
12
13
|
from ..logger import logger
|
|
13
14
|
from ..utils import is_valid_uuid, libVersion, OutputValue
|
|
14
15
|
from ..exceptions import (
|
|
@@ -66,6 +67,22 @@ from .durable_callback import (
|
|
|
66
67
|
)
|
|
67
68
|
from .ui import RequenceUI, create_ui
|
|
68
69
|
from .ui_watch import UIWatchListener, find_ui_by_id, watch_ui_rebuilds
|
|
70
|
+
# The store's handle type and its named refusals (#211). `StoreSlot` is exported
|
|
71
|
+
# because it is how an author pins the value type — Python has no call-site type
|
|
72
|
+
# argument, so the annotation is the only place to say it:
|
|
73
|
+
#
|
|
74
|
+
# cursor: StoreSlot[int] = context.store.private('lastUid', 'taskTemplate')
|
|
75
|
+
from ..store import (
|
|
76
|
+
StoreAddressFullException,
|
|
77
|
+
StoreException,
|
|
78
|
+
StoreRequestException,
|
|
79
|
+
StoreSlot,
|
|
80
|
+
StoreTaskNotAllowedException,
|
|
81
|
+
StoreUnauthorizedException,
|
|
82
|
+
StoreUnavailableException,
|
|
83
|
+
StoreValueNotStorableException,
|
|
84
|
+
StoreValueTooLargeException,
|
|
85
|
+
)
|
|
69
86
|
|
|
70
87
|
__all__ = [
|
|
71
88
|
'Service',
|
|
@@ -77,6 +94,15 @@ __all__ = [
|
|
|
77
94
|
'create_durable_callback',
|
|
78
95
|
'RequenceUI',
|
|
79
96
|
'create_ui',
|
|
97
|
+
'StoreSlot',
|
|
98
|
+
'StoreException',
|
|
99
|
+
'StoreUnavailableException',
|
|
100
|
+
'StoreRequestException',
|
|
101
|
+
'StoreUnauthorizedException',
|
|
102
|
+
'StoreTaskNotAllowedException',
|
|
103
|
+
'StoreAddressFullException',
|
|
104
|
+
'StoreValueTooLargeException',
|
|
105
|
+
'StoreValueNotStorableException',
|
|
80
106
|
]
|
|
81
107
|
|
|
82
108
|
MessageHandlerFunction = Callable[[Context[Any, Any]], Any | None]
|
|
@@ -591,6 +617,11 @@ class Service:
|
|
|
591
617
|
)
|
|
592
618
|
)
|
|
593
619
|
|
|
620
|
+
# Mirroring the loss logged in `__run`: without this, a recovery is
|
|
621
|
+
# completely silent and indistinguishable from a hang. Logged before the
|
|
622
|
+
# flag is set, so the initial connect stays quiet.
|
|
623
|
+
if self.__ever_connected:
|
|
624
|
+
logger.info("Requence AMQP reconnected")
|
|
594
625
|
self.__ever_connected = True
|
|
595
626
|
# Set BEFORE the blocking consume: everything a caller of `start()` needs —
|
|
596
627
|
# the connection, both channels, the topology — is in place, and the next
|
|
@@ -623,6 +654,10 @@ class Service:
|
|
|
623
654
|
outage it exists for."""
|
|
624
655
|
backoff = 1.0
|
|
625
656
|
while not self.__closing:
|
|
657
|
+
# `__generation` only advances on a connection that reached the
|
|
658
|
+
# consume, so comparing it after the attempt says whether this
|
|
659
|
+
# attempt got a live connection or merely failed to make one.
|
|
660
|
+
generation = self.__generation
|
|
626
661
|
try:
|
|
627
662
|
self.__connect_and_consume()
|
|
628
663
|
return # start_consuming returned normally: close() stopped us.
|
|
@@ -643,6 +678,14 @@ class Service:
|
|
|
643
678
|
|
|
644
679
|
if self.__closing:
|
|
645
680
|
return
|
|
681
|
+
# Backoff exists to space out attempts against a broker that is down,
|
|
682
|
+
# so it belongs to a run of consecutive FAILED connects. An attempt
|
|
683
|
+
# that connected and then lost the connection hours later starts a new
|
|
684
|
+
# outage: without this reset it would inherit the previous outage's
|
|
685
|
+
# wait and sit out up to 30s before a retry that would have succeeded
|
|
686
|
+
# immediately.
|
|
687
|
+
if self.__generation != generation:
|
|
688
|
+
backoff = 1.0
|
|
646
689
|
time.sleep(min(backoff, 30.0) + random.uniform(0.0, 1.0))
|
|
647
690
|
backoff = min(backoff * 2.0, 30.0)
|
|
648
691
|
|
|
@@ -1296,6 +1339,12 @@ class Service:
|
|
|
1296
1339
|
# minted before it existed, which then simply cannot emit one, and the
|
|
1297
1340
|
# callback handler says exactly that.
|
|
1298
1341
|
node_id = payload.get("nodeId")
|
|
1342
|
+
# Set only when this dispatch is a configuration-function evaluation
|
|
1343
|
+
# (#224). `nodeId` is then the HOST node's — the node being
|
|
1344
|
+
# configured — and the store composes `private` slots into that
|
|
1345
|
+
# node's configuration box. Not spelled `configuration`: that key is
|
|
1346
|
+
# already this envelope's configuration VALUE.
|
|
1347
|
+
configuration_eval = payload.get("configurationEval") is True
|
|
1299
1348
|
|
|
1300
1349
|
deferred = False
|
|
1301
1350
|
deferred_reason: str | None = None
|
|
@@ -1486,7 +1535,19 @@ class Service:
|
|
|
1486
1535
|
on_log=on_log,
|
|
1487
1536
|
on_defer=on_defer,
|
|
1488
1537
|
terminated=terminated,
|
|
1489
|
-
on_render=lambda ui, props, surface_id: on_render(ui, props, surface_id)
|
|
1538
|
+
on_render=lambda ui, props, surface_id: on_render(ui, props, surface_id),
|
|
1539
|
+
# The whole of what a node needs to address a slot (#211): the
|
|
1540
|
+
# two opaque fields ui/backend minted for this tree, plus the
|
|
1541
|
+
# two ids this dispatch already carries. The service composes no
|
|
1542
|
+
# address and holds no store password — the store builds the
|
|
1543
|
+
# address from the capability.
|
|
1544
|
+
store=Store(
|
|
1545
|
+
url=options.get("storeUrl"),
|
|
1546
|
+
signature=options.get("storeSignature"),
|
|
1547
|
+
task_id=task_id,
|
|
1548
|
+
node_id=node_id,
|
|
1549
|
+
configuration=configuration_eval,
|
|
1550
|
+
),
|
|
1490
1551
|
)
|
|
1491
1552
|
|
|
1492
1553
|
# The one stamp per node execution: this build, this box. It becomes
|