AMGI (Asynchronous Messaging Gateway Interface) Specification¶
Abstract¶
This document proposes a standard interface between messaging protocol servers (Kafka, AQMP, MQTT) and Python applications, intended to allow for writing applications that can support multiple event protocols.
This base specification aims to establish a fixed set of APIs through which these servers interact and execute application code.
Rationale¶
The ASGI standard has proved itself in the world of webservers, webservers such as uvicorn have proved itself in production, and frameworks such as FastAPI are among the top most started projects on GitHub.
One of the most useful feature of ASGI is its portability, with Mangum allowing you to run ASGI compatible applications within AWS Lambda.
AMGI aims to achieve this level of portability to support messaging protocols, it takes the lessons from ASGI and attempts to have a similar simple application interface.
AMGI has two main goals:
Provide a way to write an application to handle messages, and without modification support multiple protocols.
Allow for a simple method of portability in terms of compute, you should be able to run your application anywhere, whether that be on a persistent server, or a serverless environment
Overview¶
ASGI consists of two components:
A protocol server, consumes messages from the specific protocol, and sends any messages the .
An application, which lives inside a protocol server, this is called once per batch of messages (dependent on protocol), the application will emit events to send, and acknowledgements when a message is processed.
Like ASGI, applications are called, and awaited with a scope, along with two awaitable callables: receive()
event messages, and send() event messages back. All this happening in an asynchronous event loop.