Skip to content
ItalyPaleAlePublic

About

The simple & low-maintenance Go distributed actor framework and workflow engine

Topics

Resources

Stars

93 stars

Watchers

2 watching

Forks

Latest commit

 

History

333 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Francis logo

Francis: the simple & low-maintenance Go distributed actor framework

📚 Read the documentation

Francis is a framework and runtime for Distributed Actors (also known as durable objects) for Go apps, and a durable workflow engine built on them.

With Francis, you can build highly-available apps that scale horizontally and/or use microservices. Unlike other actor frameworks, Francis is designed to be simpler to add to your solution and lower-maintenance: it only requires a relational database (PostgreSQL or SQLite) and can optionally run embedded in your apps too, without a separate control plane service.

What you can use Francis for:

  • Build stateful services where each entity (a user, a device, a shopping cart, a game session…) is an actor with its own durable state
  • Run multi-step workflows that survive restarts and undo the work that already succeeded when a later step fails
  • Run background work on a schedule with durable alarms that survive restarts
  • Process a distributed pool of long-running tasks with a bounded number per host that scales out as you add hosts
  • Add resilience to microservices without standing up extra infrastructure beyond a database
// An actor is just a Go struct that implements one or more methods
func (c *Counter) Invoke(ctx context.Context, method string, data actor.Envelope) (any, error) {
	state, _ := c.client.GetState(ctx)
	state.Count++
	_ = c.client.SetState(ctx, state, nil)
	return state.Count, nil
}

A workflow is a declared graph of steps, each one a plain Go function:

checkout, _ := workflow.New("checkout",
	workflow.WithSteps(
		workflow.Step("reserve-inventory",
			workflow.WithRun(reserveInventory),
			workflow.WithCompensate(releaseInventory),
		),
		workflow.Step("charge",
			workflow.WithRun(chargeCard),
			workflow.WithCompensate(refundCharge),
		),
		workflow.Step("create-shipment", workflow.WithRun(createShipment)),
	),
)

If create-shipment fails, Francis runs refundCharge and then releaseInventory, and the instance terminates as failed.

Francis is fully open source and released under a permissive MIT license.

If you're new to the distributed actors pattern, this article provides a good starting point.

Key features

  • Virtual actors: actors are addressed by type and ID, activated on demand, and run one invocation at a time (turn-based concurrency), so you never manage their lifecycle or worry about concurrent access to their state
  • Durable state: each actor has its own state, persisted in PostgreSQL or SQLite, which survives deactivation, restarts, and moving between hosts
  • Durable alarms: schedule one-off or repeating work that survives process restarts
  • Durable workflows: declare a multi-step process as a graph, with parallel steps, fan-out, child workflows, and a per-step undo that runs in reverse when the process fails
  • Two topologies, same code: run everything embedded in your app (local) with no extra services, or point your workers at a standalone runtime (remote) when you want a dedicated control plane
  • Low-maintenance: the only hard dependency is a relational database, no separate message broker or external coordination service
  • Secure by default: hosts authenticate each other with mTLS using certificates derived from a shared cluster key, with pluggable host bootstrap (pre-shared key or JWT)
  • Built for Go: a small, idiomatic API built around the standard library, context.Context, and generics

Quick start

Add Francis to your Go module:

go get github.com/italypaleale/francis

Create an actor host with an embedded SQLite store (the local topology, which requires no additional services), register your actor, and run it:

h, err := local.NewHost(
	local.WithAddress("127.0.0.1:7571"),
	local.WithSQLiteProvider(local.SQLiteProviderOptions{
		ConnectionString: "data.db",
	}),
	// The runtime PSK derives the cluster CA used for host-to-host mTLS
	local.WithRuntimePSKs([]byte("change-me-please")),
)
if err != nil {
	log.Fatal(err)
}

// Register actor types before running the host
err = h.RegisterActor("counter", NewCounter)
if err != nil {
	log.Fatal(err)
}

// h.Service() lets you invoke actors and manage their state and alarms
err = h.Run(context.Background())

See the Quickstart for the complete, runnable walkthrough.

Documentation

All documentation lives on the website.

Quick links:

You can also find runnable samples in the examples directory.

License

Francis is open source software released under a permissive MIT license. See LICENSE.

What's in the name? As an actor framework, Francis is named after the world-famous movie director Francis Ford Coppola

About

The simple & low-maintenance Go distributed actor framework and workflow engine

Topics

Resources

Stars

93 stars

Watchers

2 watching

Forks

Releases

Used by

Contributors

Languages