ActualLab.Core
ActualLab.Core is the foundational library providing essential primitives used throughout Fusion and ActualLab.Rpc. It includes time abstractions, collections, async utilities, serialization infrastructure, and more.
Required Package
| Package | Purpose |
|---|---|
| ActualLab.Core | Core infrastructure library |
Namespace Overview
ActualLab (Root)
Core types used throughout the library. See Result and Option for details.
| Type | Description | Source |
|---|---|---|
Result<T> | Success/error result type | Result.cs |
Option<T> | Optional value type | Option.cs |
Requirement<T> | Validation constraint that throws on failure | Requirement.cs |
HostId | Unique identifier for a host/process instance | HostId.cs |
ActualLab.Time
Unix-style time primitives. See Time documentation for details.
| Type | Description | Source |
|---|---|---|
Moment | Unix-epoch timestamp (ticks since 1970-01-01 UTC) | Moment.cs |
CpuTimestamp | High-resolution elapsed time measurement | CpuTimestamp.cs |
MomentClock | Abstract time source | MomentClock.cs |
MomentClockSet | DI-friendly clock container | MomentClockSet.cs |
RetryDelaySeq | Delay sequence generator for retries | RetryDelaySeq.cs |
ActualLab.Async
Async/await utilities and patterns.
| Type | Description | Source |
|---|---|---|
AsyncLock | Async-compatible mutual exclusion lock | AsyncLock.cs |
AsyncLockSet<TKey> | Keyed async locks (lock per entity) | AsyncLockSet.cs |
AsyncState<T> | Thread-safe mutable state with change notifications | AsyncState.cs |
BatchProcessor<TIn, TOut> | Batches concurrent requests for efficient processing | BatchProcessor.cs |
AsyncChain | Composable async operation chains | AsyncChain.cs |
WorkerBase | Background worker with lifecycle management | WorkerBase.cs |
TaskExt | Extension methods for Task (suppress, collect, etc.) | TaskExt.cs |
See also:
ActualLab.Collections
Specialized collections and data structures. See PropertyBag documentation for details.
| Type | Description | Source |
|---|---|---|
PropertyBag | Immutable key-value store with type-decorated serialization | PropertyBag.cs |
MutablePropertyBag | Mutable variant of PropertyBag | MutablePropertyBag.cs |
MemoryBuffer<T> | Pooled, resizable buffer (like ArrayPool-backed list) | MemoryBuffer.cs |
RingBuffer<T> | Fixed-size circular buffer | RingBuffer.cs |
ImmutableBimap<K, V> | Bidirectional immutable dictionary | ImmutableBimap.cs |
BinaryHeap<T> | Priority queue implementation | BinaryHeap.cs |
RadixHeapSet<T> | Fast priority queue for scheduling | RadixHeapSet.cs |
ActualLab.Serialization
Unified serialization infrastructure. See Unified Serialization for details.
| Type | Description | Source |
|---|---|---|
IByteSerializer | Binary serialization abstraction | IByteSerializer.cs |
ITextSerializer | Text/JSON serialization abstraction | ITextSerializer.cs |
ByteSerialized<T> | Lazy byte serialization wrapper | ByteSerialized.cs |
TextSerialized<T> | Lazy text serialization wrapper | TextSerialized.cs |
UniSerialized<T> | Multi-format serialization wrapper | UniSerialized.cs |
TypeDecoratingTextSerializer | Preserves type info for polymorphism | TypeDecoratingTextSerializer.cs |
ActualLab.Locking
Synchronization primitives. See AsyncLock documentation for details.
| Type | Description | Source |
|---|---|---|
AsyncLock | Async-compatible lock with using pattern | AsyncLock.cs |
AsyncLockSet<TKey> | Keyed async locks (lock per entity) | AsyncLockSet.cs |
FileLock | Cross-process file-based lock | FileLock.cs |
ActualLab.Resilience
Fault tolerance and retry logic. See Transiency documentation for details.
| Type | Description | Source |
|---|---|---|
RetryPolicy | Configurable retry with backoff | RetryPolicy.cs |
Transiency | Classifies exceptions as transient/terminal | Transiency.cs |
TransiencyResolver | Determines if an exception is transient | TransiencyResolver.cs |
ChaosMaker | Injects random failures for testing | ChaosMaker.cs |
ActualLab.Caching
Caching infrastructure.
| Type | Description | Source |
|---|---|---|
FileSystemCache | Simple file-based cache | FileSystemCache.cs |
MemoizingCache<TKey, TValue> | In-memory memoization cache | MemoizingCache.cs |
ActualLab.Versioning
Version tracking for optimistic concurrency.
| Type | Description | Source |
|---|---|---|
VersionGenerator<T> | Generates monotonic version numbers | VersionGenerator.cs |
VersionSet<T> | Tracks multiple version ranges (used in RPC for API versioning) | VersionSet.cs |
ActualLab.Text
String and text utilities. See Symbol documentation for details.
| Type | Description | Source |
|---|---|---|
Symbol | Interned string for fast equality checks | Symbol.cs |
ListFormat | Parses/formats delimited lists | ListFormat.cs |
Extension Methods
ActualLab.Core provides numerous extension methods:
| Class | Purpose | Source |
|---|---|---|
TaskExt | Task manipulation (suppress exceptions, collect results) | TaskExt.cs |
CancellationTokenExt | Cancellation token utilities | CancellationTokenExt.cs |
ExceptionExt | Exception handling helpers | ExceptionExt.cs |
EnumerableExt | LINQ extensions | EnumerableExt.cs |
SpanExt | Span/Memory utilities | SpanExt.cs |
StringExt | String manipulation | StringExt.cs |
DI Integration
Register core services:
services.AddSingleton(MomentClockSet.Default);
// Access via extension
var clocks = services.Clocks();
var commander = services.Commander();