Myxo¶
Myxo is a Python framework for services that run together in one process or apart on several machines, with the same code. A file, the layout, says which service runs where. Moving a service to another process, or giving it replicas, changes that file and leaves the code alone.
Version 0.2
Myxo is at version 0.2, on PyPI. Any name may change in a minor release until 1.0. See the known limits before relying on it.
-
Write two services, then run them in one process and in two.
-
Take a guestbook from one process on SQLite to replicas on PostgreSQL.
-
Publish events, run jobs and schedules, deploy, and operate an installation.
-
Look up the commands, the layout file and the Python API.
An application in one file of configuration¶
A service is a class. Other services call it through a typed interface:
class Greeter(Service):
name = "greeter"
api = GreeterAPI
async def greet(self, who: Name) -> Greeting:
return Greeting(f"Hello, {who.name}!")
The caller asks for a client and never learns where the service runs:
The layout decides. This one runs both services in one process, where the call is a method call:
This one runs them in two, where the same call crosses a Unix socket:
[processes.web]
services = ["web"]
[processes.greeter]
services = ["greeter"]
url = "unix:run/greeter.sock"
Both give the caller the same timeout and the same errors.
What comes with it¶
- Layouts place the services in processes from one TOML file, which reads the environment.
- Supervision restarts a failed service with a backoff, and
/readyzreports each process's readiness. - Checks in
myxo checkfind a mutable message, or an import from another package that bypasses an interface, before anything starts.
All of these run on SQLite and on PostgreSQL, with no Redis and no broker:
- Events commit in the caller's transaction, and reach consumer groups after it.
- Jobs wait in a durable queue, with retries and leases.
- Schedules run periodic work from one leader in the installation.
- Caches live in the process, or in a table that every process shares.
- Push streams events to browsers, and resumes after a reconnection.
myxo export writes a platform's files from the layout:
- systemd gets units for a server with no platform.
- Hop3 gets a Procfile and
hop3.toml. - Kubernetes gets a migration job, deployments, services, network policies and a Dockerfile.
From a laptop to replicas¶
An installation moves through five steps, each changing configuration alone:
| Step | What changes |
|---|---|
| 0. Develop | services and a layout: one process, SQLite |
| 1. One box | a layout with two processes on one machine |
| 2. A real database | DATABASE_URL |
| 3. Process types on a platform | the platform's files, from myxo export |
| 4. Replicas | an instance count, on PostgreSQL |
One installation went through all five with no change to its code, in three runs (E14).
For language models¶
This site publishes llms.txt, an index of its pages for language models and coding assistants, and the Markdown source of each page beside it.