Class TyphonOptions
Fluent configuration for the one-line Typhon setup surface — AddTyphon(IServiceCollection, Action<TyphonOptions>) and Open(string, Action<TyphonOptions>, ILoggerFactory).
public sealed class TyphonOptions
- Inheritance
-
TyphonOptions
- Inherited Members
Remarks
TyphonOptions is a thin façade: it accumulates configuration delegates that target the real option types (Typhon.Engine.Internals.MemoryAllocatorOptions, Typhon.Engine.Internals.ManagedPagedMMFOptions, DatabaseEngineOptions). It declares no duplicate settings of its own, so validation and defaults stay on those leaf types (see issue #148).
Register<T>() is AOT-safe: it captures a closed-generic delegate to
RegisterComponentFromAccessor<T>(ChangeSet, SchemaValidationMode) at configuration time, when its component type T is
statically known. No Type-keyed reflection (MakeGenericType / MakeGenericMethod) is used on
this path, so the trimmer preserves every instantiation.
Constructors
TyphonOptions()
public TyphonOptions()
Methods
ConfigureEngine(Action<DatabaseEngineOptions>)
Advanced: adjust the DatabaseEngineOptions directly (WAL, resources, timeouts, etc.).
public TyphonOptions ConfigureEngine(Action<DatabaseEngineOptions> configure)
Parameters
configureAction<DatabaseEngineOptions>
Returns
ConfigureMemoryAllocator(Action<MemoryAllocatorOptions>)
Advanced: adjust the Typhon.Engine.Internals.MemoryAllocatorOptions directly.
public TyphonOptions ConfigureMemoryAllocator(Action<MemoryAllocatorOptions> configure)
Parameters
configureAction<MemoryAllocatorOptions>
Returns
ConfigureSpatialGrid(SpatialGridConfig)
Configures the engine-wide spatial grid — required when a registered archetype has a [SpatialIndex] field.
The one-line setup applies this in the narrow window after archetypes are touched and before
InitializeArchetypes() (which AddTyphon(IServiceCollection, Action<TyphonOptions>) /
Open(string, Action<TyphonOptions>, ILoggerFactory) run for
you), so you don't have to reach for the manual Add* chain just to call
ConfigureSpatialGrid(SpatialGridConfig). Only the first create of a spatial database needs this — the grid
config is persisted, so a later reopen reconstructs it without this call.
public TyphonOptions ConfigureSpatialGrid(SpatialGridConfig config)
Parameters
configSpatialGridConfig
Returns
ConfigureStorage(Action<ManagedPagedMMFOptions>)
Advanced: adjust the storage Typhon.Engine.Internals.ManagedPagedMMFOptions directly (page-cache size, etc.).
public TyphonOptions ConfigureStorage(Action<ManagedPagedMMFOptions> configure)
Parameters
configureAction<ManagedPagedMMFOptions>
Returns
DatabaseFile(string)
Sets the database file. The canonical extension is .typhon; any extension is stripped and the file stem
becomes the database name, its directory the database directory. A bare name (no directory) resolves against the
current working directory.
public TyphonOptions DatabaseFile(string path)
Parameters
pathstringThe database path, e.g.
"game.typhon"or"data/game.typhon".
Returns
Remarks
The .typhon extension is canonical now; the engine still materialises the on-disk file with its current
convention until the .typhon bundle format lands (issue #450). This method is the single point that will
swing to the bundle path, so callers should not encode the on-disk extension themselves.
PageCacheSize(ulong)
Sets the page-cache size in bytes — the discoverable front for DatabaseCacheSize. The default is 256 MiB; size it for your workload's transaction working set (a cache too small for it hits PageCacheBackpressureTimeoutException). Must be a multiple of the 8 KiB page size, and between 2 MiB and 4 GiB.
public TyphonOptions PageCacheSize(ulong bytes)
Parameters
bytesulongCache size in bytes, e.g.
512UL * 1024 * 1024for 512 MiB.
Returns
Register<T>()
Registers a component type for the engine. AOT-safe: captures a closed-generic call to RegisterComponentFromAccessor<T>(ChangeSet, SchemaValidationMode), applied once the engine is built.
public TyphonOptions Register<T>() where T : unmanaged
Returns
Type Parameters
TThe blittable component type.
Seed(int, Action<Transaction>)
Registers a data-seeding step tagged with a monotonic revision. On every open the engine applies each
registered step whose revision is greater than the database's committed seed revision, in ascending revision order,
each inside its own durable transaction — bringing the instance up to date. Call it once per revision as your app evolves:
o.Seed(1, tx => { /* initial data */ })
.Seed(2, tx => { /* data introduced in revision 2 */ });
A fresh database runs every step; an existing one runs only the steps it has not applied yet. It is crash-safe: each
step advances the committed revision in the same transaction as its data, so a crash anywhere in a step rolls both
back and that step re-runs on the next open (a partial step never leaves committed data). Write your data through the
supplied Transaction (tx.Spawn/tx.OpenMut); the engine commits each step for you.
public TyphonOptions Seed(int revision, Action<Transaction> step)
Parameters
revisionintThe step's revision. Must be >= 1 and unique across all Seed(int, Action<Transaction>) calls on these options.
stepAction<Transaction>The seeding action for this revision, given its open transaction. Do all of the step's work in that one transaction so it commits (and, on failure, rolls back) atomically.