Skip to main content

amgi-cloudevents

CloudEvents HTTP adapter for AMGI applications.

Installation

pip install "amgi-cloudevents[uvicorn]==0.46.0"

Receiving CloudEvents

from amgi_cloudevents import run
from asyncfast import AsyncFast

app = AsyncFast()


@app.channel("com.example.event")
async def handle_event(payload: bytes) -> None: ...


if __name__ == "__main__":
    run(app, host="0.0.0.0", port=8000)

You can also run an app through the AsyncFast CLI entry point:

asyncfast run amgi-cloudevents-uvicorn main:app --host 0.0.0.0 --port 8000

If the app sends follow-up messages, provide an outbound CloudEvents endpoint:

asyncfast run amgi-cloudevents-uvicorn main:app \
  --message-send-endpoint https://example.com/events \
  --message-send-source /orders \
  --message-send-content-mode binary

Server accepts binary or structured CloudEvents on POST /event by default. CloudEvent attributes and extensions are exposed as AMGI headers. For example, ce-id: event-1 becomes (b"id", b"event-1").

AMGI message.ack returns 204 No Content. AMGI message.nack returns 500 with the nack message as the response body. Invalid CloudEvents return 400.

Sending CloudEvents

from amgi_cloudevents import MessageSend
from amgi_cloudevents import Server

message_send = MessageSend(
    "https://example.com/events",
    source="/orders",
    content_mode="binary",
)
server = Server(app, message_send=message_send)

MessageSend maps AMGI message.send events to CloudEvents:

  • event["address"] becomes the CloudEvent type
  • event["payload"] becomes the CloudEvent data
  • event["headers"] become CloudEvent attributes/extensions
  • source defaults to /amgi-cloudevents, unless the AMGI headers include source

content_mode can be "structured" or "binary". Structured mode is the default.

If Server receives an AMGI message.send event without a configured message_send, it raises an error explaining that outbound sending must be wired explicitly.

Download files

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

Source Distribution

amgi_cloudevents-0.46.0.tar.gz (4.2 kB view details)

Uploaded Source

Built Distribution

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

amgi_cloudevents-0.46.0-py3-none-any.whl (6.2 kB view details)

Uploaded Python 3

File details

Details for the file amgi_cloudevents-0.46.0.tar.gz.

File metadata

  • Download URL: amgi_cloudevents-0.46.0.tar.gz
  • Upload date:
  • Size: 4.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for amgi_cloudevents-0.46.0.tar.gz
Algorithm Hash digest
SHA256 837f241699ff504746993f683258eafc2f55c8fe839e1336a5218d2ecaf42713
MD5 c99b16e795f58200c37e86219c79819f
BLAKE2b-256 27a882eb0cf7c877298bd46d5ba4c29f0b81328638d0c709342af7480f13bbbd

See more details on using hashes here.

File details

Details for the file amgi_cloudevents-0.46.0-py3-none-any.whl.

File metadata

  • Download URL: amgi_cloudevents-0.46.0-py3-none-any.whl
  • Upload date:
  • Size: 6.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for amgi_cloudevents-0.46.0-py3-none-any.whl
Algorithm Hash digest
SHA256 03d546ccff557801d2f2488c82f2381c733ed1adb0792c24ad176a2a72b0d148
MD5 f8354151f2c483136a8f087ae7bc1446
BLAKE2b-256 3daa45a59507d1e287b6c64be0343d73bce09a7f90c9297f11d5ffbe0f4f15e2

See more details on using hashes here.

Release history Release notifications | RSS feed

0.47.0

2 files

This release

0.46.0 This release

2 files

0.45.1

2 files

0.45.0

2 files

0.44.0

2 files

0.43.0

2 files

0.42.0

2 files

0.41.1

2 files

0.41.0

2 files

0.40.0

2 files

Supported by

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