Skip to main content

Shared Prophet event publisher runtime

Project description

Prophet logo


prophet-events-runtime

prophet-events-runtime is the shared Python runtime contract used by Prophet-generated action services.

Main project repository:

It defines:

  • an async EventPublisher protocol
  • a canonical EventWireEnvelope dataclass
  • TransitionValidationResult for generated transition-validator hooks
  • utility helpers (create_event_id, now_iso)
  • sync bridge helpers (publish_sync, publish_batch_sync)
  • a NoOpEventPublisher for local wiring and tests

Install

python3 -m pip install prophet-events-runtime

API

from typing import Iterable, Protocol

class EventPublisher(Protocol):
    async def publish(self, envelope: EventWireEnvelope) -> None: ...
    async def publish_batch(self, envelopes: Iterable[EventWireEnvelope]) -> None: ...
from dataclasses import dataclass
from typing import Dict, List, Optional

@dataclass(kw_only=True)
class EventWireEnvelope:
    event_id: str
    trace_id: str
    event_type: str
    schema_version: str
    occurred_at: str
    source: str
    payload: Dict[str, object]
    attributes: Optional[Dict[str, str]] = None
    updated_objects: Optional[List[Dict[str, object]]] = None

Exports:

  • EventPublisher
  • EventWireEnvelope
  • NoOpEventPublisher
  • create_event_id()
  • now_iso()
  • publish_sync(publisher, envelope)
  • publish_batch_sync(publisher, envelopes)
  • TransitionValidationResult

Implement a Platform Publisher

from __future__ import annotations

from typing import Iterable

from prophet_events_runtime import EventPublisher
from prophet_events_runtime import EventWireEnvelope


class PlatformClient:
    async def send_event(self, payload: dict) -> None: ...
    async def send_events(self, payloads: list[dict]) -> None: ...


class PlatformEventPublisher(EventPublisher):
    def __init__(self, client: PlatformClient) -> None:
        self._client = client

    async def publish(self, envelope: EventWireEnvelope) -> None:
        await self._client.send_event(envelope.__dict__)

    async def publish_batch(self, envelopes: Iterable[EventWireEnvelope]) -> None:
        await self._client.send_events([envelope.__dict__ for envelope in envelopes])

With Prophet-Generated Code

Generated Python action services publish event wire envelopes after successful handler execution. If you do not provide an implementation, you can wire NoOpEventPublisher for local development.

Local Validation

From repository root:

PYTHONPATH=prophet-lib/python/src python3 -m unittest discover -s prophet-lib/python/tests -p 'test_*.py' -v
.venv/bin/pip install -r requirements-dev.txt
.venv/bin/python -m build prophet-lib/python
.venv/bin/python -m twine check prophet-lib/python/dist/*

More Information

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

prophet_events_runtime-0.6.0.tar.gz (3.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

prophet_events_runtime-0.6.0-py3-none-any.whl (4.3 kB view details)

Uploaded Python 3

File details

Details for the file prophet_events_runtime-0.6.0.tar.gz.

File metadata

  • Download URL: prophet_events_runtime-0.6.0.tar.gz
  • Upload date:
  • Size: 3.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for prophet_events_runtime-0.6.0.tar.gz
Algorithm Hash digest
SHA256 0740cd08e53768c92ede245c302d51a8af1cfe0f575c197f479f34b5a593b968
MD5 7c16854961a2a47098d616504fc8e452
BLAKE2b-256 bf9c65e61540d33748e52fc4d0a5b293fcdd092decd0fdb98daacce1b9dc789d

See more details on using hashes here.

Provenance

The following attestation bundles were made for prophet_events_runtime-0.6.0.tar.gz:

Publisher: publish-prophet-lib.yml on Chainso/prophet

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file prophet_events_runtime-0.6.0-py3-none-any.whl.

File metadata

File hashes

Hashes for prophet_events_runtime-0.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 db67d7417fdee5ea6aef055802ef0a9a1b025eb4ca87f73aabb8daeda345efec
MD5 a0205ed3c7ececbca2d5ff7f4037f785
BLAKE2b-256 a81bc6a52b6a5a95077575b27e1d141fcc7250898c3572e2f5bb0e6af6aeb978

See more details on using hashes here.

Provenance

The following attestation bundles were made for prophet_events_runtime-0.6.0-py3-none-any.whl:

Publisher: publish-prophet-lib.yml on Chainso/prophet

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page