Skip to content

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

PackagePurpose
ActualLab.CoreCore infrastructure library

Namespace Overview

ActualLab (Root)

Core types used throughout the library. See Result and Option for details.

TypeDescriptionSource
Result<T>Success/error result typeResult.cs
Option<T>Optional value typeOption.cs
Requirement<T>Validation constraint that throws on failureRequirement.cs
HostIdUnique identifier for a host/process instanceHostId.cs

ActualLab.Time

Unix-style time primitives. See Time documentation for details.

TypeDescriptionSource
MomentUnix-epoch timestamp (ticks since 1970-01-01 UTC)Moment.cs
CpuTimestampHigh-resolution elapsed time measurementCpuTimestamp.cs
MomentClockAbstract time sourceMomentClock.cs
MomentClockSetDI-friendly clock containerMomentClockSet.cs
RetryDelaySeqDelay sequence generator for retriesRetryDelaySeq.cs

ActualLab.Async

Async/await utilities and patterns.

TypeDescriptionSource
AsyncLockAsync-compatible mutual exclusion lockAsyncLock.cs
AsyncLockSet<TKey>Keyed async locks (lock per entity)AsyncLockSet.cs
AsyncState<T>Thread-safe mutable state with change notificationsAsyncState.cs
BatchProcessor<TIn, TOut>Batches concurrent requests for efficient processingBatchProcessor.cs
AsyncChainComposable async operation chainsAsyncChain.cs
WorkerBaseBackground worker with lifecycle managementWorkerBase.cs
TaskExtExtension methods for Task (suppress, collect, etc.)TaskExt.cs

See also:

ActualLab.Collections

Specialized collections and data structures. See PropertyBag documentation for details.

TypeDescriptionSource
PropertyBagImmutable key-value store with type-decorated serializationPropertyBag.cs
MutablePropertyBagMutable variant of PropertyBagMutablePropertyBag.cs
MemoryBuffer<T>Pooled, resizable buffer (like ArrayPool-backed list)MemoryBuffer.cs
RingBuffer<T>Fixed-size circular bufferRingBuffer.cs
ImmutableBimap<K, V>Bidirectional immutable dictionaryImmutableBimap.cs
BinaryHeap<T>Priority queue implementationBinaryHeap.cs
RadixHeapSet<T>Fast priority queue for schedulingRadixHeapSet.cs

ActualLab.Serialization

Unified serialization infrastructure. See Unified Serialization for details.

TypeDescriptionSource
IByteSerializerBinary serialization abstractionIByteSerializer.cs
ITextSerializerText/JSON serialization abstractionITextSerializer.cs
ByteSerialized<T>Lazy byte serialization wrapperByteSerialized.cs
TextSerialized<T>Lazy text serialization wrapperTextSerialized.cs
UniSerialized<T>Multi-format serialization wrapperUniSerialized.cs
TypeDecoratingTextSerializerPreserves type info for polymorphismTypeDecoratingTextSerializer.cs

ActualLab.Locking

Synchronization primitives. See AsyncLock documentation for details.

TypeDescriptionSource
AsyncLockAsync-compatible lock with using patternAsyncLock.cs
AsyncLockSet<TKey>Keyed async locks (lock per entity)AsyncLockSet.cs
FileLockCross-process file-based lockFileLock.cs

ActualLab.Resilience

Fault tolerance and retry logic. See Transiency documentation for details.

TypeDescriptionSource
RetryPolicyConfigurable retry with backoffRetryPolicy.cs
TransiencyClassifies exceptions as transient/terminalTransiency.cs
TransiencyResolverDetermines if an exception is transientTransiencyResolver.cs
ChaosMakerInjects random failures for testingChaosMaker.cs

ActualLab.Caching

Caching infrastructure.

TypeDescriptionSource
FileSystemCacheSimple file-based cacheFileSystemCache.cs
MemoizingCache<TKey, TValue>In-memory memoization cacheMemoizingCache.cs

ActualLab.Versioning

Version tracking for optimistic concurrency.

TypeDescriptionSource
VersionGenerator<T>Generates monotonic version numbersVersionGenerator.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.

TypeDescriptionSource
SymbolInterned string for fast equality checksSymbol.cs
ListFormatParses/formats delimited listsListFormat.cs

Extension Methods

ActualLab.Core provides numerous extension methods:

ClassPurposeSource
TaskExtTask manipulation (suppress exceptions, collect results)TaskExt.cs
CancellationTokenExtCancellation token utilitiesCancellationTokenExt.cs
ExceptionExtException handling helpersExceptionExt.cs
EnumerableExtLINQ extensionsEnumerableExt.cs
SpanExtSpan/Memory utilitiesSpanExt.cs
StringExtString manipulationStringExt.cs

DI Integration

Register core services:

cs
services.AddSingleton(MomentClockSet.Default);

// Access via extension
var clocks = services.Clocks();
var commander = services.Commander();