Skip to content
Orleans.FSharp logo

Orleans.FSharp

Build Orleans grains in idiomatic F#. Immutable state transitions, computation expressions, and zero boilerplate C# stubs. 1500+ tests.

Microsoft Orleans is one of the strongest virtual actor runtimes on .NET. But in raw C# style, F# teams often end up with mutable state classes, attribute noise, and repetitive infrastructure code.

Orleans.FSharp keeps full Orleans power while giving you a functional-first authoring model: computation expressions for grain and hosting setup, explicit state transitions, and typed message flows.

type CounterGrain() =
inherit Grain<int>()
override this.OnActivateAsync(ct) =
this.State <- 0
Task.CompletedTask
member this.Increment() =
this.State <- this.State + 1
this.WriteStateAsync()
let counter = grain {
defaultState 0
handle (fun state cmd ->
task {
match cmd with
| Increment -> return state + 1, box(state + 1)
})
persist "Default"
}

The F# version is shorter, immutable, and the compiler checks exhaustive pattern matching.

grain { } CE

Define grains declaratively with rich CE keywords: state machines, handlers, lifecycle hooks, reminders, timers, and persistence in idiomatic F#.

siloConfig { } CE

Configure clustering, storage, streaming, TLS, health checks, and runtime services without extension-method boilerplate.

eventSourcedGrain { } CE

Event sourcing with pure apply/handle functions and a runtime bridge that keeps event persistence integration straightforward.

FSharpBinaryCodec

Serialize F# DUs, records, options, lists, and maps with minimal ceremony and predictable behavior for mixed cluster scenarios.

1500+ Tests

1500+ unit and integration tests, including property-based verification with FsCheck and autogenerated data via GrainArbitrary.

.NET 10 Ready

Orleans 10 parity with negligible local wrapper overhead compared to real network and storage costs.

MetricValue
Test suite1500+ unit + integration tests
CE keywords85+ across grain {}, siloConfig {}, clientConfig {}, eventSourcedGrain {}
Orleans parity100% — Orleans 10 feature surface
NuGet packages7 — core, runtime, testing, event sourcing, analyzers, generator, templates
LicenseMIT
Local API overhead~8ns in benchmark scenarios
Terminal window
dotnet new install Orleans.FSharp.Templates
dotnet new orleans-fsharp -n MyApp
cd MyApp
dotnet build && dotnet test

A working Orleans.FSharp solution with a counter grain, FsCheck property tests, and silo configuration — ready in under 2 minutes.

Orleans.FSharp

Core developer surface: grain CE, GrainRef, streaming, logging, reminders, timers, observers, serialization.

Orleans.FSharp.Runtime

Hosting and client runtime: siloConfig {} and clientConfig {} builders for production setup.

Orleans.FSharp.Abstractions

C# shim for Orleans proxy generation around IFSharpGrain (reference from silo, no hand-written stubs).

Orleans.FSharp.EventSourcing

Event-sourced grains with eventSourcedGrain { } and runtime integration helpers.

Orleans.FSharp.Testing

TestHarness, WebTestHarness, MockGrainFactory, GrainArbitrary, and log capture utilities.

Orleans.FSharp.Analyzers

Compile-time safety checks (for example OF0001 for async { }) with explicit opt-out where needed.

Every major Orleans capability, wrapped in idiomatic F#:

  • Grain lifecycle: activate, deactivate, lifecycle hooks
  • State persistence: Memory, Redis, Azure Blob/Table, Cosmos, DynamoDB, ADO.NET
  • Streaming: Memory, Event Hubs, Azure Queue, broadcast channels, TaskSeq
  • Reentrancy & concurrency: Reentrant grains, interleaved methods, stateless workers
  • Placement strategies: Prefer local, random, hash-based, activation count, resource-optimized, silo role
  • Event sourcing: eventSourcedGrain { } with snapshot strategies
  • Transactions: TransactionalState wrapper for ACID operations
  • Observers & filters: Incoming/outgoing grain call filters, request context propagation
  • TLS/mTLS: Certificate-based silo and client encryption
  • Health checks & OpenTelemetry: Production observability out of the box
  • Kubernetes clustering: native K8s support with namespace and clustering configuration