DEV Community

Roman Chudov
Roman Chudov

Posted on

Floxy — a lightweight workflow engine for GoLang with saga-style compensation

Floxy — a lightweight workflow engine for Go with saga-style compensation

When building distributed systems or long-running business processes, we often need workflows that can retry, rollback, and recover — without introducing the complexity of Temporal.

That’s where Floxy fits in.


What is Floxy?

Floxy is a lightweight workflow engine for Go.

It provides a simple builder API and a deterministic runtime that supports saga-style compensation, save points, and idempotency control — all without external dependencies or background daemons.

It’s designed to be small, composable, and transparent.


Key features

  • Deterministic state machine execution
  • Retry and compensation policies
  • Partial rollback via save points
  • Idempotency control (WithStepNoIdempotent)
  • Parallel, fork, and join support
  • Event-driven persistence for observability

Example

wf := floxy.NewBuilder("order_saga", 1).
    Step("reserve_funds", "ReserveFunds").
        OnFailure("refund_funds", "RefundFunds").
    Step("ship_order", "ShipOrder").
        OnFailure("cancel_shipping", "CancelShipping").
    Step("notify_user", "Notify").
    Build()
Enter fullscreen mode Exit fullscreen mode


`

If ship_order fails:

  1. Floxy marks it as failed.
  2. Executes its compensation handler cancel_shipping.
  3. Rolls back previous steps (refund_funds).
  4. Marks the workflow as failed deterministically.

Retry and Idempotency

In Floxy, MaxRetries defines the total number of allowed handler calls, including the first one.

  • MaxRetries = 1 → one call only (no retries).
  • MaxRetries = 3 → up to three total executions.

By default, steps are idempotent.
To mark a step as non-idempotent, use:

go
Step("charge_card", "ChargeCard", floxy.WithStepNoIdempotent())

This ensures the handler runs exactly once, even if it fails.


Deterministic State Model

Floxy models workflows as a finite state machine:


pending → running → completed

failed → compensation → rolled_back

Each state transition is explicit and persisted in storage, which makes recovery and auditing reliable and predictable.


When to use Floxy

Floxy is ideal for:

  • Transactional workflows with rollback logic (saga pattern)
  • ETL or provisioning pipelines
  • Payment, booking, and inventory systems
  • Temporal-like semantics without Temporal’s infrastructure

Learn more

GitHub: github.com/rom8726/floxy

The repository includes a detailed docs/ENGINE_SPEC.md describing the internal runtime model, retry semantics, and compensation flow.

If you find Floxy useful, give it a star and share feedback.


Floxy: deterministic workflows for real systems, built the Go way.

Top comments (0)