Skip to content

Repository files navigation

Axial

Axial

Write asynchronous F# workflows whose expected failures and required dependencies are visible in their types.

ci docs NuGet License

Warning

Axial is pre-1.0 and its API may change before the first stable release.

Your first flow

A handler usually needs services and can fail, but a Task signature shows neither fact. Flow<'env, 'error, 'value> makes both part of the contract.

open Axial

type CheckoutError =
    | OrderNotFound of orderId: int
    | PaymentDeclined of reason: string

type Receipt = { OrderId: int; Total: decimal; Reference: string }

type CheckoutEnv =
    { FindTotal: int -> ColdTask<Result<decimal, CheckoutError>>
      Charge: decimal -> ColdTask<Result<string, CheckoutError>> }

let checkout orderId : Flow<CheckoutEnv, CheckoutError, Receipt> =
    flow {
        let! findTotal = Flow.envWith _.FindTotal
        let! charge = Flow.envWith _.Charge
        let! total = findTotal orderId
        let! reference = charge total
        return { OrderId = orderId; Total = total; Reference = reference }
    }

The application supplies live functions. A test supplies a record of fakes. The workflow does not change.

Adding a timeout, a retry policy, and a resource that must be released does not change the signature either, because the runtime that starts the workflow owns cancellation, retries, and cleanup:

open System

let checkoutOrder orderId : Flow<CheckoutEnv, CheckoutError, Receipt> =
    checkout orderId
    |> Flow.Runtime.retry (RetryPolicy.noDelay 3)
    |> Flow.Runtime.timeout (TimeSpan.FromSeconds 5.0) (PaymentDeclined "checkout timed out")

Flow also carries concurrency, scheduling, streams, and structured child fibers through the same runtime.

Install

dotnet add package Axial

Packages

The core is independent. Add service and hosting packages only when the workflow uses them.

  • Axial — workflows, typed failures, dependencies, concurrency, schedules, streams, and layers
  • Axial.PlatformService — explicit clock, logging, randomness, GUID, and environment services
  • Axial.Console, Axial.FileSystem, Axial.HttpClient, Axial.Process — mockable operational services
  • Axial.Hosting, Axial.Hosting.Node, Axial.Hosting.Browser — application lifecycle integrations
  • Axial.Telemetry — tracing and runtime observability
  • Axial.Hosting.AspNetCore, Axial.Hosting.GenHttp — optional adapters for serving Reified HTTP contracts

Documentation and examples

Reified integration

Reified declares value, model, JSON, and HTTP contracts. Axial's optional server adapters execute Reified HTTP contracts as workflows; neither core depends on the other.

Declare a contract with Reified. Serve it with Axial.

About

Ergonomic asynchronous F# workflows whose expected failures and required dependencies are visible in their types.

Topics

Resources

Stars

4 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages