This page documents Orleans.Lattice.GrainIndex 9.9.0, in the documentation for Orleans.Lattice 9.9.0 (release line 9.9), built 2026-10-04. It is also published as markdown, with every table and list, at api.md, and llms.txt lists every page.
The public surface of Orleans.Lattice.GrainIndex. Types live in the
Orleans.Lattice.GrainIndex namespace.
Orleans facet attribute standing in for [PersistentState], marking a grain's state as indexed. Takes an optional state name and storage name.
IndexedGrain<TState>
Optional base class exposing State, RecordExists, Etag, PersistentState, and WriteStateAsync/ReadStateAsync/ClearStateAsync. It holds no enrolment logic: it forwards to the [Indexed] state object, whose write publishes the grain's entries, whose re-read reconciles them against what it reads, and whose clear withdraws them.
Querying
Type
Purpose
IGrainIndexProvider
Resolves a declared index. GetIndex<TGrain, TState>(string? name = null) and DeclaredIndexes.
IGrainIndex<TGrain, TState>
One index. Name, IndexedProperties, and Where(Expression<Func<TState, bool>>).
GrainIndex<TGrain, TState>
The concrete index implementing IGrainIndex<TGrain, TState>, resolved through IGrainIndexProvider rather than constructed directly.
IGrainIndexQuery<TGrain>
A planned, immutable query. See below.
GrainIndexQueryExecution
DurableCursor (default), Stream, SnapshotCursor.
GrainIndexMatch
A matched grain paired with the entry that matched it.
GrainIndexQueryDefaults
The defaults a planned query starts from: PageSize (256) and Execution (DurableCursor).
IGrainIndexQuery<TGrain>
Member
Purpose
PageSize
Entries fetched per round trip.
Execution
How the query walks the tree.
WithPageSize(int)
Returns a new query with the given page size.
WithExecution(GrainIndexQueryExecution)
Returns a new query with the given execution mode.
ToGrainsAsync(CancellationToken)
Streams matching grain references, each once.
ToKeysAsync(CancellationToken)
Streams matching encoded grain keys, each once. The cheapest shape.
The application-supplied key population. EnumerateKeysAsync(string? resumeAfterExclusive, CancellationToken) and the optional TryGetApproximateCountAsync(CancellationToken).
IGrainIndexBackfillActivator
The replaceable seam the backfill uses to onboard one dormant grain: ActivateAsync(IGrainIndexDefinition, string grainKey, CancellationToken) brings the grain into existence so its [Indexed] state enrols it. The default addresses the grain through the index's key codec and asks the runtime to deactivate it when idle.
GrainIndexBackfillState
NotStarted, Running, Paused, Completed, Failed.
GrainIndexBackfillStatus
A crawl's state, checkpoint, and progress.
GrainIndexBackfillBatchResult
The outcome of one pass.
GrainIndexProgress
Processed count, optional total and percentage, the last key visited (LastProcessedKey, the crawl's resume point), and why the last pass failed (LastError, retained across a resume).
Whether the declaration drifted, and on which fields.
GrainIndexMetrics
MeterName and Meter - the shared core meter (LatticeMetrics.Meter), not a package meter - plus the eight instruments and their names, the tag names and path values, and IndexTag(string), which caches one index tag per index name.
Per-index settings, resolved by name through IOptionsMonitor<GrainIndexOptions>.Get(indexName).
GrainIndexOutboxOptions
Silo-wide outbox drain settings.
GrainIndexDeclarationOptions
The silo's whole declaration set: Definitions lists every AddGrainIndex declaration (IGrainIndexDefinition) in registration order, validated as a set at startup.
GrainIndexDriftPolicy
Reject (default) or Rebuild.
GrainIndexProjectionMode
When entries are published relative to the state write: Synchronous (default) or Eventual.
The diff between an intended and a stored projection.
GrainIndexMaintainer<TGrain, TState>
Applies an update plan to the tree.
GrainIndexEntry
One index entry.
GrainIndexEntryValue
The entry payload encoding.
Exceptions
Exception
Thrown when
GrainIndexNotDeclaredException
An administrative call names an index this silo does not declare. Resolving an unknown index through IGrainIndexProvider throws InvalidOperationException instead.
GrainIndexPropertyNotIndexedException
A predicate names a property that is not Included. Reports the index, the path, and the indexed properties.
GrainIndexConfigurationDriftException
A drift-breaking declaration change is rejected at startup. Names the index and the drifted fields.
GrainIndexReplicationNotAllowedException
An index tree is configured to replicate while AllowReplication is false.
GrainIndexKeyEncodingException
A grain key cannot be encoded or decoded by the index's codec, or - from AddGrainIndex - a declaration supplies no WithKeyCodec and no built-in codec matches TGrain (it declares none, or more than one, of the string, Guid and integer key interfaces).