relay-runtime 0.1.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.
@@ -0,0 +1,10 @@
1
+ """Official public interfaces for developing Python handlers on Relay.
2
+
3
+ The initial release publishes the ``HandlerContext`` Protocol. Relay's Python
4
+ bootstrap constructs the actual per-invocation context object.
5
+ """
6
+
7
+ from relay_runtime.typing import HandlerContext
8
+
9
+ __all__ = ["HandlerContext"]
10
+ __version__ = "0.1.0"
relay_runtime/py.typed ADDED
File without changes
@@ -0,0 +1,73 @@
1
+ """Public handler interfaces for Python applications running on Relay.
2
+
3
+ The initial release exposes ``HandlerContext``, a Protocol describing the
4
+ context object Relay passes to each handler. Relay's Python bootstrap
5
+ constructs the concrete per-invocation value.
6
+ """
7
+
8
+ from datetime import datetime
9
+ from typing import Protocol
10
+
11
+ __all__ = ["HandlerContext"]
12
+
13
+
14
+ class HandlerContext(Protocol):
15
+ """Metadata Relay supplies for exactly one handler invocation.
16
+
17
+ A handler receives a fresh instance as its second argument. Implementations
18
+ are structural: any object with these attributes and method satisfies the
19
+ contract, and handlers should treat the values as read-only.
20
+ """
21
+
22
+ @property
23
+ def request_id(self) -> str:
24
+ """Stable identity for one logical invocation.
25
+
26
+ Retries, redeliveries, and worker restarts reuse it for the same invocation.
27
+ State-free executions such as manual invocations and dead-letter replays get
28
+ a fresh identity.
29
+ """
30
+ ...
31
+
32
+ @property
33
+ def attempt(self) -> int:
34
+ """1-based attempt number, starting at 1 for the initial execution."""
35
+ ...
36
+
37
+ @property
38
+ def max_attempts(self) -> int:
39
+ """Configured total attempt budget (initial attempt plus retries).
40
+
41
+ A configuration change can leave :attr:`attempt` above this value, so it is
42
+ not an upper bound for the current attempt.
43
+ """
44
+ ...
45
+
46
+ @property
47
+ def deadline(self) -> datetime:
48
+ """Absolute, timezone-aware instant when the invocation is cancelled."""
49
+ ...
50
+
51
+ @property
52
+ def message_id(self) -> str | None:
53
+ """Source stream message identity, or ``None`` when no source exists."""
54
+ ...
55
+
56
+ @property
57
+ def trace_id(self) -> str | None:
58
+ """W3C trace ID for the invocation, or ``None`` when tracing is absent."""
59
+ ...
60
+
61
+ @property
62
+ def app(self) -> str:
63
+ """Name of the app that owns the handler."""
64
+ ...
65
+
66
+ @property
67
+ def handler(self) -> str:
68
+ """Handler identity, in the same form used by the app manifest."""
69
+ ...
70
+
71
+ def get_remaining_time_ms(self) -> int:
72
+ """Return milliseconds left before :attr:`deadline`, clamped at zero."""
73
+ ...
@@ -0,0 +1,103 @@
1
+ Metadata-Version: 2.4
2
+ Name: relay-runtime
3
+ Version: 0.1.0
4
+ Summary: Official Python library and public handler interfaces for Relay applications.
5
+ Keywords: relay,application-development,handlers
6
+ Author: Relay Contributors
7
+ License-Expression: GPL-3.0-or-later
8
+ License-File: LICENSE
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: Typing :: Typed
11
+ Requires-Python: >=3.14
12
+ Description-Content-Type: text/markdown
13
+
14
+ # relay-runtime
15
+
16
+ The official Python library for developing Relay applications and using Relay's
17
+ public handler interfaces.
18
+
19
+ The package is optional for Relay's execution. Add it as a normal application
20
+ dependency when your handlers import it. Its initial release publishes the
21
+ `HandlerContext` structural Protocol; Relay's Python bootstrap constructs the
22
+ actual context object for each invocation and passes it to the handler.
23
+
24
+ ## Install
25
+
26
+ With uv:
27
+
28
+ ```sh
29
+ uv add relay-runtime
30
+ ```
31
+
32
+ Or with pip:
33
+
34
+ ```sh
35
+ pip install relay-runtime
36
+ ```
37
+
38
+ The library supports Python 3.14 and newer.
39
+
40
+ ## Handler example
41
+
42
+ Relay calls a handler with the event as its first argument and the context as
43
+ its second:
44
+
45
+ ```python
46
+ from relay_runtime.typing import HandlerContext
47
+
48
+
49
+ async def handler(event: dict, context: HandlerContext) -> None:
50
+ print(
51
+ f"request {context.request_id} "
52
+ f"has {context.get_remaining_time_ms()}ms left"
53
+ )
54
+ ```
55
+
56
+ `HandlerContext` is a public `typing.Protocol`, not the concrete context
57
+ implementation. Relay's Python bootstrap creates and supplies that actual
58
+ per-invocation object. The current release provides `HandlerContext`; later
59
+ releases may add application-development utilities.
60
+
61
+ ## Contract
62
+
63
+ `HandlerContext` provides:
64
+
65
+ | Member | Type | Meaning |
66
+ | ------------------------- | ------------- | --------------------------------------------- |
67
+ | `request_id` | `str` | Stable identity for one logical invocation |
68
+ | `attempt` | `int` | 1-based attempt number |
69
+ | `max_attempts` | `int` | Configured total attempt budget |
70
+ | `deadline` | `datetime` | Absolute, timezone-aware cancellation instant |
71
+ | `message_id` | `str \| None` | Source message identity when one exists |
72
+ | `trace_id` | `str \| None` | W3C trace ID when tracing is enabled |
73
+ | `app` | `str` | Owning app name |
74
+ | `handler` | `str` | Handler identity |
75
+ | `get_remaining_time_ms()` | `int` | Milliseconds left, clamped at zero |
76
+
77
+ `max_attempts` is the configured budget, not an upper bound on `attempt`: a
78
+ configuration change can leave a claimed attempt above the current budget.
79
+
80
+ The package version is independent of the Relay release version. Future
81
+ releases may add exports, and existing members keep their documented meaning.
82
+
83
+ ## Development
84
+
85
+ The package is managed with [uv](https://docs.astral.sh/uv/) and uses a `src`
86
+ layout with the `uv_build` backend.
87
+
88
+ ```sh
89
+ cd packages/python
90
+ uv lock
91
+ uv sync --locked
92
+ uv run mypy
93
+ uv build
94
+ uv run pytest
95
+ ```
96
+
97
+ `uv.lock` is committed so installs and checks resolve the same versions. The
98
+ `dev` dependency group contains mypy and pytest only; neither is required by
99
+ handlers or by the package at runtime.
100
+
101
+ ## License
102
+
103
+ GPL-3.0-or-later. See [LICENSE](LICENSE).
@@ -0,0 +1,7 @@
1
+ relay_runtime/__init__.py,sha256=mcuCC5lIsKcjyqSGlTYow__CweS5fJXqYXE_BUL2acM,318
2
+ relay_runtime/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
+ relay_runtime/typing.py,sha256=bT8eArF_mt8shuaRJaHRNLVnNNHT90ILs-ARDbhUzzI,2250
4
+ relay_runtime-0.1.0.dist-info/licenses/LICENSE,sha256=8Em-hR-B5eTrDCLW9n16tBGMdLb2cyR7SHSpFxXtBUY,702
5
+ relay_runtime-0.1.0.dist-info/WHEEL,sha256=XV0cjMrO7zXhVAIyyc8aFf1VjZ33Fen4IiJk5zFlC3g,80
6
+ relay_runtime-0.1.0.dist-info/METADATA,sha256=K1etdjY6XbV9tBUZhdVJ_71axZSGnnlT9v9zcfi7o8g,3478
7
+ relay_runtime-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: uv 0.9.26
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,17 @@
1
+ GNU GENERAL PUBLIC LICENSE
2
+ Version 3, 29 June 2007
3
+
4
+ Copyright (C) 2026 Relay Contributors
5
+
6
+ This program is free software: you can redistribute it and/or modify
7
+ it under the terms of the GNU General Public License as published by
8
+ the Free Software Foundation, either version 3 of the License, or
9
+ (at your option) any later version.
10
+
11
+ This program is distributed in the hope that it will be useful,
12
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ GNU General Public License for more details.
15
+
16
+ You should have received a copy of the GNU General Public License
17
+ along with this program. If not, see <https://www.gnu.org/licenses/>.