moxzi
Docs / Actor platforms / Orleans

Orleansalpha

Run Motoko actors as Orleans grains, with state in Postgres and Orleans reminders as timers.

Each actor key is an Orleans grain in the silo. Orleans places it and delivers its messages one at a time; its state is stored in Postgres, and timers are Orleans reminders.

You also need the moxzi SDK and hosts bundles; see Actor platforms.

Prerequisites#

Create and run a project#

moxzi host new orleans hello
cd hello
ONCE=1 ./run.sh

Among the build and platform log lines, the demo prints Counter/1.inc() -> [1]. Run it again and it prints [2]: the host is a new process, and the actor's state comes back from the platform's store.

ONCE=1 exits after the demo. Without it, the host keeps running on port 8090 (set PORT to change it), and you can call any key:

curl -X POST localhost:8090/actors/Counter/2/method/inc \
  -H 'content-type: application/json' -d '[]'

--example ledger and --example saga work on Orleans too; see Examples.

The project#

PathContents
actor.moThe Counter actor type. Each key Counter/ID is a separate actor
host/moxzi's Orleans adapter. It's yours to change
run.shBuilds the actor and the host, starts what Orleans needs, and runs the demo

Change actor.mo and run ./run.sh again. New keys use the new code. Existing keys keep their code until they're upgraded; host/README.md describes upgrades.

How it maps#

Handled by
One message at a time per keyThe Orleans grain
PlacementThe Orleans cluster
Actor statePostgres, in a Docker container named moxzi-hello-pg on port 55432 that run.sh starts and leaves running. Set DATABASE_URL to use your own database, or PG_PORT to use another port
Durable timersOrleans reminders

Remove the database container with docker rm -f moxzi-hello-pg when you're done.

Configuration#

VariableDefaultEffect
PORT8090The host's HTTP port
MOXZI_HOST_TOKENrandomToken for the host's control endpoints (/_moxzi/*)
DATABASE_URLa local containerPostgres connection string
PG_PORT55432Port for the local Postgres container. All projects use the same default, so only one can run at a time
On this pagePrerequisitesCreate and run a projectThe projectHow it mapsConfiguration