prophet-events-runtime 0.2.1__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.
- prophet_events_runtime-0.2.1/PKG-INFO +120 -0
- prophet_events_runtime-0.2.1/README.md +112 -0
- prophet_events_runtime-0.2.1/pyproject.toml +17 -0
- prophet_events_runtime-0.2.1/setup.cfg +4 -0
- prophet_events_runtime-0.2.1/src/prophet_events_runtime/__init__.py +17 -0
- prophet_events_runtime-0.2.1/src/prophet_events_runtime/publisher.py +47 -0
- prophet_events_runtime-0.2.1/src/prophet_events_runtime/wire.py +16 -0
- prophet_events_runtime-0.2.1/src/prophet_events_runtime.egg-info/PKG-INFO +120 -0
- prophet_events_runtime-0.2.1/src/prophet_events_runtime.egg-info/SOURCES.txt +10 -0
- prophet_events_runtime-0.2.1/src/prophet_events_runtime.egg-info/dependency_links.txt +1 -0
- prophet_events_runtime-0.2.1/src/prophet_events_runtime.egg-info/top_level.txt +1 -0
- prophet_events_runtime-0.2.1/tests/test_runtime.py +38 -0
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: prophet-events-runtime
|
|
3
|
+
Version: 0.2.1
|
|
4
|
+
Summary: Shared Prophet event publisher runtime
|
|
5
|
+
Author: Prophet
|
|
6
|
+
Requires-Python: >=3.10
|
|
7
|
+
Description-Content-Type: text/markdown
|
|
8
|
+
|
|
9
|
+
<p align="center">
|
|
10
|
+
<img src="https://raw.githubusercontent.com/Chainso/prophet/main/brand/exports/logo-horizontal-color.png" alt="Prophet logo" />
|
|
11
|
+
</p>
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
# prophet-events-runtime
|
|
16
|
+
|
|
17
|
+
`prophet-events-runtime` is the shared Python runtime contract used by Prophet-generated action services.
|
|
18
|
+
|
|
19
|
+
Main project repository:
|
|
20
|
+
- https://github.com/Chainso/prophet
|
|
21
|
+
|
|
22
|
+
It defines:
|
|
23
|
+
- an async `EventPublisher` protocol
|
|
24
|
+
- a canonical `EventWireEnvelope` dataclass
|
|
25
|
+
- utility helpers (`create_event_id`, `now_iso`)
|
|
26
|
+
- sync bridge helpers (`publish_sync`, `publish_batch_sync`)
|
|
27
|
+
- a `NoOpEventPublisher` for local wiring and tests
|
|
28
|
+
|
|
29
|
+
## Install
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
python3 -m pip install prophet-events-runtime
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## API
|
|
36
|
+
|
|
37
|
+
```python
|
|
38
|
+
from typing import Iterable, Protocol
|
|
39
|
+
|
|
40
|
+
class EventPublisher(Protocol):
|
|
41
|
+
async def publish(self, envelope: EventWireEnvelope) -> None: ...
|
|
42
|
+
async def publish_batch(self, envelopes: Iterable[EventWireEnvelope]) -> None: ...
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
```python
|
|
46
|
+
from dataclasses import dataclass
|
|
47
|
+
from typing import Dict, Optional
|
|
48
|
+
|
|
49
|
+
@dataclass(kw_only=True)
|
|
50
|
+
class EventWireEnvelope:
|
|
51
|
+
event_id: str
|
|
52
|
+
trace_id: str
|
|
53
|
+
event_type: str
|
|
54
|
+
schema_version: str
|
|
55
|
+
occurred_at: str
|
|
56
|
+
source: str
|
|
57
|
+
payload: Dict[str, object]
|
|
58
|
+
attributes: Optional[Dict[str, str]] = None
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
Exports:
|
|
62
|
+
- `EventPublisher`
|
|
63
|
+
- `EventWireEnvelope`
|
|
64
|
+
- `NoOpEventPublisher`
|
|
65
|
+
- `create_event_id()`
|
|
66
|
+
- `now_iso()`
|
|
67
|
+
- `publish_sync(publisher, envelope)`
|
|
68
|
+
- `publish_batch_sync(publisher, envelopes)`
|
|
69
|
+
|
|
70
|
+
## Implement a Platform Publisher
|
|
71
|
+
|
|
72
|
+
```python
|
|
73
|
+
from __future__ import annotations
|
|
74
|
+
|
|
75
|
+
from typing import Iterable
|
|
76
|
+
|
|
77
|
+
from prophet_events_runtime import EventPublisher
|
|
78
|
+
from prophet_events_runtime import EventWireEnvelope
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
class PlatformClient:
|
|
82
|
+
async def send_event(self, payload: dict) -> None: ...
|
|
83
|
+
async def send_events(self, payloads: list[dict]) -> None: ...
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
class PlatformEventPublisher(EventPublisher):
|
|
87
|
+
def __init__(self, client: PlatformClient) -> None:
|
|
88
|
+
self._client = client
|
|
89
|
+
|
|
90
|
+
async def publish(self, envelope: EventWireEnvelope) -> None:
|
|
91
|
+
await self._client.send_event(envelope.__dict__)
|
|
92
|
+
|
|
93
|
+
async def publish_batch(self, envelopes: Iterable[EventWireEnvelope]) -> None:
|
|
94
|
+
await self._client.send_events([envelope.__dict__ for envelope in envelopes])
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## With Prophet-Generated Code
|
|
98
|
+
|
|
99
|
+
Generated Python action services publish event wire envelopes after successful handler execution.
|
|
100
|
+
If you do not provide an implementation, you can wire `NoOpEventPublisher` for local development.
|
|
101
|
+
|
|
102
|
+
## Local Validation
|
|
103
|
+
|
|
104
|
+
From repository root:
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
PYTHONPATH=prophet-lib/python/src python3 -m unittest discover -s prophet-lib/python/tests -p 'test_*.py' -v
|
|
108
|
+
python3 -m pip install --upgrade build twine
|
|
109
|
+
python3 -m build prophet-lib/python
|
|
110
|
+
python3 -m twine check prophet-lib/python/dist/*
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
## More Information
|
|
114
|
+
|
|
115
|
+
- Main repository README: https://github.com/Chainso/prophet#readme
|
|
116
|
+
- Runtime index: https://github.com/Chainso/prophet/tree/main/prophet-lib
|
|
117
|
+
- Event wire contract: https://github.com/Chainso/prophet/tree/main/prophet-lib/specs/wire-contract.md
|
|
118
|
+
- Event wire JSON schema: https://github.com/Chainso/prophet/tree/main/prophet-lib/specs/wire-event-envelope.schema.json
|
|
119
|
+
- Python integration reference: https://github.com/Chainso/prophet/tree/main/docs/reference/python.md
|
|
120
|
+
- Example app: https://github.com/Chainso/prophet/tree/main/examples/python/prophet_example_fastapi_sqlalchemy
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="https://raw.githubusercontent.com/Chainso/prophet/main/brand/exports/logo-horizontal-color.png" alt="Prophet logo" />
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# prophet-events-runtime
|
|
8
|
+
|
|
9
|
+
`prophet-events-runtime` is the shared Python runtime contract used by Prophet-generated action services.
|
|
10
|
+
|
|
11
|
+
Main project repository:
|
|
12
|
+
- https://github.com/Chainso/prophet
|
|
13
|
+
|
|
14
|
+
It defines:
|
|
15
|
+
- an async `EventPublisher` protocol
|
|
16
|
+
- a canonical `EventWireEnvelope` dataclass
|
|
17
|
+
- utility helpers (`create_event_id`, `now_iso`)
|
|
18
|
+
- sync bridge helpers (`publish_sync`, `publish_batch_sync`)
|
|
19
|
+
- a `NoOpEventPublisher` for local wiring and tests
|
|
20
|
+
|
|
21
|
+
## Install
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
python3 -m pip install prophet-events-runtime
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## API
|
|
28
|
+
|
|
29
|
+
```python
|
|
30
|
+
from typing import Iterable, Protocol
|
|
31
|
+
|
|
32
|
+
class EventPublisher(Protocol):
|
|
33
|
+
async def publish(self, envelope: EventWireEnvelope) -> None: ...
|
|
34
|
+
async def publish_batch(self, envelopes: Iterable[EventWireEnvelope]) -> None: ...
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
```python
|
|
38
|
+
from dataclasses import dataclass
|
|
39
|
+
from typing import Dict, Optional
|
|
40
|
+
|
|
41
|
+
@dataclass(kw_only=True)
|
|
42
|
+
class EventWireEnvelope:
|
|
43
|
+
event_id: str
|
|
44
|
+
trace_id: str
|
|
45
|
+
event_type: str
|
|
46
|
+
schema_version: str
|
|
47
|
+
occurred_at: str
|
|
48
|
+
source: str
|
|
49
|
+
payload: Dict[str, object]
|
|
50
|
+
attributes: Optional[Dict[str, str]] = None
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Exports:
|
|
54
|
+
- `EventPublisher`
|
|
55
|
+
- `EventWireEnvelope`
|
|
56
|
+
- `NoOpEventPublisher`
|
|
57
|
+
- `create_event_id()`
|
|
58
|
+
- `now_iso()`
|
|
59
|
+
- `publish_sync(publisher, envelope)`
|
|
60
|
+
- `publish_batch_sync(publisher, envelopes)`
|
|
61
|
+
|
|
62
|
+
## Implement a Platform Publisher
|
|
63
|
+
|
|
64
|
+
```python
|
|
65
|
+
from __future__ import annotations
|
|
66
|
+
|
|
67
|
+
from typing import Iterable
|
|
68
|
+
|
|
69
|
+
from prophet_events_runtime import EventPublisher
|
|
70
|
+
from prophet_events_runtime import EventWireEnvelope
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
class PlatformClient:
|
|
74
|
+
async def send_event(self, payload: dict) -> None: ...
|
|
75
|
+
async def send_events(self, payloads: list[dict]) -> None: ...
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
class PlatformEventPublisher(EventPublisher):
|
|
79
|
+
def __init__(self, client: PlatformClient) -> None:
|
|
80
|
+
self._client = client
|
|
81
|
+
|
|
82
|
+
async def publish(self, envelope: EventWireEnvelope) -> None:
|
|
83
|
+
await self._client.send_event(envelope.__dict__)
|
|
84
|
+
|
|
85
|
+
async def publish_batch(self, envelopes: Iterable[EventWireEnvelope]) -> None:
|
|
86
|
+
await self._client.send_events([envelope.__dict__ for envelope in envelopes])
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
## With Prophet-Generated Code
|
|
90
|
+
|
|
91
|
+
Generated Python action services publish event wire envelopes after successful handler execution.
|
|
92
|
+
If you do not provide an implementation, you can wire `NoOpEventPublisher` for local development.
|
|
93
|
+
|
|
94
|
+
## Local Validation
|
|
95
|
+
|
|
96
|
+
From repository root:
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
PYTHONPATH=prophet-lib/python/src python3 -m unittest discover -s prophet-lib/python/tests -p 'test_*.py' -v
|
|
100
|
+
python3 -m pip install --upgrade build twine
|
|
101
|
+
python3 -m build prophet-lib/python
|
|
102
|
+
python3 -m twine check prophet-lib/python/dist/*
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
## More Information
|
|
106
|
+
|
|
107
|
+
- Main repository README: https://github.com/Chainso/prophet#readme
|
|
108
|
+
- Runtime index: https://github.com/Chainso/prophet/tree/main/prophet-lib
|
|
109
|
+
- Event wire contract: https://github.com/Chainso/prophet/tree/main/prophet-lib/specs/wire-contract.md
|
|
110
|
+
- Event wire JSON schema: https://github.com/Chainso/prophet/tree/main/prophet-lib/specs/wire-event-envelope.schema.json
|
|
111
|
+
- Python integration reference: https://github.com/Chainso/prophet/tree/main/docs/reference/python.md
|
|
112
|
+
- Example app: https://github.com/Chainso/prophet/tree/main/examples/python/prophet_example_fastapi_sqlalchemy
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=68", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "prophet-events-runtime"
|
|
7
|
+
version = "0.2.1"
|
|
8
|
+
description = "Shared Prophet event publisher runtime"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.10"
|
|
11
|
+
authors = [{ name = "Prophet" }]
|
|
12
|
+
|
|
13
|
+
[tool.setuptools]
|
|
14
|
+
package-dir = {"" = "src"}
|
|
15
|
+
|
|
16
|
+
[tool.setuptools.packages.find]
|
|
17
|
+
where = ["src"]
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
from .publisher import EventPublisher
|
|
2
|
+
from .publisher import NoOpEventPublisher
|
|
3
|
+
from .publisher import create_event_id
|
|
4
|
+
from .publisher import now_iso
|
|
5
|
+
from .publisher import publish_batch_sync
|
|
6
|
+
from .publisher import publish_sync
|
|
7
|
+
from .wire import EventWireEnvelope
|
|
8
|
+
|
|
9
|
+
__all__ = [
|
|
10
|
+
"EventPublisher",
|
|
11
|
+
"EventWireEnvelope",
|
|
12
|
+
"NoOpEventPublisher",
|
|
13
|
+
"create_event_id",
|
|
14
|
+
"now_iso",
|
|
15
|
+
"publish_sync",
|
|
16
|
+
"publish_batch_sync",
|
|
17
|
+
]
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import asyncio
|
|
4
|
+
from datetime import datetime, timezone
|
|
5
|
+
from typing import Iterable, Protocol
|
|
6
|
+
from uuid import uuid4
|
|
7
|
+
|
|
8
|
+
from .wire import EventWireEnvelope
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class EventPublisher(Protocol):
|
|
12
|
+
async def publish(self, envelope: EventWireEnvelope) -> None: ...
|
|
13
|
+
|
|
14
|
+
async def publish_batch(self, envelopes: Iterable[EventWireEnvelope]) -> None: ...
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class NoOpEventPublisher:
|
|
18
|
+
async def publish(self, envelope: EventWireEnvelope) -> None:
|
|
19
|
+
return None
|
|
20
|
+
|
|
21
|
+
async def publish_batch(self, envelopes: Iterable[EventWireEnvelope]) -> None:
|
|
22
|
+
return None
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def create_event_id() -> str:
|
|
26
|
+
return str(uuid4())
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def now_iso() -> str:
|
|
30
|
+
return datetime.now(timezone.utc).isoformat()
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def _run_async(coro: object) -> None:
|
|
34
|
+
try:
|
|
35
|
+
asyncio.get_running_loop()
|
|
36
|
+
except RuntimeError:
|
|
37
|
+
asyncio.run(coro) # type: ignore[arg-type]
|
|
38
|
+
return
|
|
39
|
+
raise RuntimeError("Cannot use sync publish helper while an event loop is running")
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def publish_sync(publisher: EventPublisher, envelope: EventWireEnvelope) -> None:
|
|
43
|
+
_run_async(publisher.publish(envelope))
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def publish_batch_sync(publisher: EventPublisher, envelopes: Iterable[EventWireEnvelope]) -> None:
|
|
47
|
+
_run_async(publisher.publish_batch(envelopes))
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from dataclasses import dataclass
|
|
4
|
+
from typing import Dict, Optional
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
@dataclass(kw_only=True)
|
|
8
|
+
class EventWireEnvelope:
|
|
9
|
+
event_id: str
|
|
10
|
+
trace_id: str
|
|
11
|
+
event_type: str
|
|
12
|
+
schema_version: str
|
|
13
|
+
occurred_at: str
|
|
14
|
+
source: str
|
|
15
|
+
payload: Dict[str, object]
|
|
16
|
+
attributes: Optional[Dict[str, str]] = None
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: prophet-events-runtime
|
|
3
|
+
Version: 0.2.1
|
|
4
|
+
Summary: Shared Prophet event publisher runtime
|
|
5
|
+
Author: Prophet
|
|
6
|
+
Requires-Python: >=3.10
|
|
7
|
+
Description-Content-Type: text/markdown
|
|
8
|
+
|
|
9
|
+
<p align="center">
|
|
10
|
+
<img src="https://raw.githubusercontent.com/Chainso/prophet/main/brand/exports/logo-horizontal-color.png" alt="Prophet logo" />
|
|
11
|
+
</p>
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
# prophet-events-runtime
|
|
16
|
+
|
|
17
|
+
`prophet-events-runtime` is the shared Python runtime contract used by Prophet-generated action services.
|
|
18
|
+
|
|
19
|
+
Main project repository:
|
|
20
|
+
- https://github.com/Chainso/prophet
|
|
21
|
+
|
|
22
|
+
It defines:
|
|
23
|
+
- an async `EventPublisher` protocol
|
|
24
|
+
- a canonical `EventWireEnvelope` dataclass
|
|
25
|
+
- utility helpers (`create_event_id`, `now_iso`)
|
|
26
|
+
- sync bridge helpers (`publish_sync`, `publish_batch_sync`)
|
|
27
|
+
- a `NoOpEventPublisher` for local wiring and tests
|
|
28
|
+
|
|
29
|
+
## Install
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
python3 -m pip install prophet-events-runtime
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## API
|
|
36
|
+
|
|
37
|
+
```python
|
|
38
|
+
from typing import Iterable, Protocol
|
|
39
|
+
|
|
40
|
+
class EventPublisher(Protocol):
|
|
41
|
+
async def publish(self, envelope: EventWireEnvelope) -> None: ...
|
|
42
|
+
async def publish_batch(self, envelopes: Iterable[EventWireEnvelope]) -> None: ...
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
```python
|
|
46
|
+
from dataclasses import dataclass
|
|
47
|
+
from typing import Dict, Optional
|
|
48
|
+
|
|
49
|
+
@dataclass(kw_only=True)
|
|
50
|
+
class EventWireEnvelope:
|
|
51
|
+
event_id: str
|
|
52
|
+
trace_id: str
|
|
53
|
+
event_type: str
|
|
54
|
+
schema_version: str
|
|
55
|
+
occurred_at: str
|
|
56
|
+
source: str
|
|
57
|
+
payload: Dict[str, object]
|
|
58
|
+
attributes: Optional[Dict[str, str]] = None
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
Exports:
|
|
62
|
+
- `EventPublisher`
|
|
63
|
+
- `EventWireEnvelope`
|
|
64
|
+
- `NoOpEventPublisher`
|
|
65
|
+
- `create_event_id()`
|
|
66
|
+
- `now_iso()`
|
|
67
|
+
- `publish_sync(publisher, envelope)`
|
|
68
|
+
- `publish_batch_sync(publisher, envelopes)`
|
|
69
|
+
|
|
70
|
+
## Implement a Platform Publisher
|
|
71
|
+
|
|
72
|
+
```python
|
|
73
|
+
from __future__ import annotations
|
|
74
|
+
|
|
75
|
+
from typing import Iterable
|
|
76
|
+
|
|
77
|
+
from prophet_events_runtime import EventPublisher
|
|
78
|
+
from prophet_events_runtime import EventWireEnvelope
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
class PlatformClient:
|
|
82
|
+
async def send_event(self, payload: dict) -> None: ...
|
|
83
|
+
async def send_events(self, payloads: list[dict]) -> None: ...
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
class PlatformEventPublisher(EventPublisher):
|
|
87
|
+
def __init__(self, client: PlatformClient) -> None:
|
|
88
|
+
self._client = client
|
|
89
|
+
|
|
90
|
+
async def publish(self, envelope: EventWireEnvelope) -> None:
|
|
91
|
+
await self._client.send_event(envelope.__dict__)
|
|
92
|
+
|
|
93
|
+
async def publish_batch(self, envelopes: Iterable[EventWireEnvelope]) -> None:
|
|
94
|
+
await self._client.send_events([envelope.__dict__ for envelope in envelopes])
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## With Prophet-Generated Code
|
|
98
|
+
|
|
99
|
+
Generated Python action services publish event wire envelopes after successful handler execution.
|
|
100
|
+
If you do not provide an implementation, you can wire `NoOpEventPublisher` for local development.
|
|
101
|
+
|
|
102
|
+
## Local Validation
|
|
103
|
+
|
|
104
|
+
From repository root:
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
PYTHONPATH=prophet-lib/python/src python3 -m unittest discover -s prophet-lib/python/tests -p 'test_*.py' -v
|
|
108
|
+
python3 -m pip install --upgrade build twine
|
|
109
|
+
python3 -m build prophet-lib/python
|
|
110
|
+
python3 -m twine check prophet-lib/python/dist/*
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
## More Information
|
|
114
|
+
|
|
115
|
+
- Main repository README: https://github.com/Chainso/prophet#readme
|
|
116
|
+
- Runtime index: https://github.com/Chainso/prophet/tree/main/prophet-lib
|
|
117
|
+
- Event wire contract: https://github.com/Chainso/prophet/tree/main/prophet-lib/specs/wire-contract.md
|
|
118
|
+
- Event wire JSON schema: https://github.com/Chainso/prophet/tree/main/prophet-lib/specs/wire-event-envelope.schema.json
|
|
119
|
+
- Python integration reference: https://github.com/Chainso/prophet/tree/main/docs/reference/python.md
|
|
120
|
+
- Example app: https://github.com/Chainso/prophet/tree/main/examples/python/prophet_example_fastapi_sqlalchemy
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
README.md
|
|
2
|
+
pyproject.toml
|
|
3
|
+
src/prophet_events_runtime/__init__.py
|
|
4
|
+
src/prophet_events_runtime/publisher.py
|
|
5
|
+
src/prophet_events_runtime/wire.py
|
|
6
|
+
src/prophet_events_runtime.egg-info/PKG-INFO
|
|
7
|
+
src/prophet_events_runtime.egg-info/SOURCES.txt
|
|
8
|
+
src/prophet_events_runtime.egg-info/dependency_links.txt
|
|
9
|
+
src/prophet_events_runtime.egg-info/top_level.txt
|
|
10
|
+
tests/test_runtime.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
prophet_events_runtime
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import unittest
|
|
4
|
+
|
|
5
|
+
from prophet_events_runtime import EventWireEnvelope
|
|
6
|
+
from prophet_events_runtime import NoOpEventPublisher
|
|
7
|
+
from prophet_events_runtime import create_event_id
|
|
8
|
+
from prophet_events_runtime import now_iso
|
|
9
|
+
from prophet_events_runtime import publish_batch_sync
|
|
10
|
+
from prophet_events_runtime import publish_sync
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class RuntimeTests(unittest.TestCase):
|
|
14
|
+
def test_create_event_id(self) -> None:
|
|
15
|
+
value = create_event_id()
|
|
16
|
+
self.assertTrue(value)
|
|
17
|
+
|
|
18
|
+
def test_now_iso(self) -> None:
|
|
19
|
+
value = now_iso()
|
|
20
|
+
self.assertIn("T", value)
|
|
21
|
+
|
|
22
|
+
def test_sync_helpers(self) -> None:
|
|
23
|
+
publisher = NoOpEventPublisher()
|
|
24
|
+
envelope = EventWireEnvelope(
|
|
25
|
+
event_id="evt-1",
|
|
26
|
+
trace_id="trace-1",
|
|
27
|
+
event_type="Example",
|
|
28
|
+
schema_version="1.0.0",
|
|
29
|
+
occurred_at=now_iso(),
|
|
30
|
+
source="tests",
|
|
31
|
+
payload={},
|
|
32
|
+
)
|
|
33
|
+
publish_sync(publisher, envelope)
|
|
34
|
+
publish_batch_sync(publisher, [envelope])
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
if __name__ == "__main__":
|
|
38
|
+
unittest.main()
|