Skip to content

HTTP Client

Goal: use the portable HTTP client against a running store service.

Prerequisites

python -m pip install -e ".[dev]"

Files Used

  • sssn/server/fastapi.py exposes the portable FastAPI app.
  • sssn/client/http.py implements SSSNClient and AsyncSSSNClient.
  • tests/test_http_client.py verifies the client against the API shape.

Start The Server

sssn --store .sssn serve --host 127.0.0.1 --port 7700

Call The Server

from sssn import SSSNClient

client = SSSNClient("http://127.0.0.1:7700")
client.create_channel({"name": "events", "schema": "demo.Event"})
event = client.append_event(
    {"channel": "events", "kind": "message", "payload": {"text": "hello"}}
)

assert client.get_event(event.id).payload == {"text": "hello"}

Verify

python -m pytest tests/test_http_client.py -q

Expected output:

... passed

Next, use subscriptions for restartable worker loops.