Source of truth (2026)
  • DataManagementEngineStandard/DistributedDatasource/Distributed/DistributedDataSource.cs
  • .../DistributedDataSource.Plan.cs | .Routing.cs | .Reads.cs
  • .../DistributedDataSource.Writes.cs | .Transactions.cs
  • .../DistributedDataSource.Events.cs | .Lifecycle.cs
  • .../DistributedDataSource.Resilience.cs | .Observability.cs
  • .../DistributedDataSource.Performance.cs | .Audit.cs
  • .../DistributedDataSource.Resharding.cs | .Schema.cs
  • .../DistributedDataSource.Query.cs | .IDataSource.cs
  • .../DistributedDataSource.ShardInvoker.cs
  • .../DistributedDataSourceOptions.cs
  • .../DistributedExecutionContext.cs
  • .../DistributionMode.cs
  • .../IDistributedDataSource.cs

Overview

DistributedDataSource distributes entities across multiple physical datasources (shards), each backed by an IProxyCluster. It implements IDataSource and IDistributedDataSource across 12 partial files.

Per-shard failover, circuit breaking, and load balancing are inherited from IProxyCluster.

Architecture

Partial FilePhaseResponsibility
DistributedDataSource.cs01Core state, constructors, IDataSource identity
DistributedDataSource.Plan.cs02DistributionPlan management, shard-catalog validation
DistributedDataSource.Routing.cs03-05Entity placement, shard routing
DistributedDataSource.Reads.cs06Scatter reads, replicated reads, query planning
DistributedDataSource.Writes.cs07Fan-out writes, broadcast operations
DistributedDataSource.Transactions.cs09Two-phase commit across shards
DistributedDataSource.Events.cs-Operational events
DistributedDataSource.Lifecycle.cs-Open, close, dispose orchestration
DistributedDataSource.Resilience.cs10Circuits, retries, health checks
DistributedDataSource.Observability.cs11Metrics, telemetry
DistributedDataSource.Performance.cs14Backpressure, concurrency caps
DistributedDataSource.Resharding.cs15Online resharding

Class Definition

public partial class DistributedDataSource : IDistributedDataSource
{
    public DistributedDataSource(
        IDMEEditor dmeEditor,
        IReadOnlyDictionary<string, IProxyCluster> shards,
        DistributionPlan plan = null,
        DistributedDataSourceOptions options = null);

    // IDataSource identity
    public string DatasourceName { get; set; }
    public DataSourceType DatasourceType { get; set; }
    public DatasourceCategory Category { get; set; }
    public ConnectionState ConnectionStatus { get; set; }
    public IErrorsInfo ErrorObject { get; set; }

    // Topology
    public DistributionPlan DistributionPlan { get; }
    public IReadOnlyDictionary<string, IProxyCluster> Shards { get; }

    // Executors
    private IDistributedReadExecutor _readExecutor;
    private IDistributedWriteExecutor _writeExecutor;
    private IResultMerger _resultMerger;
    private IQueryPlanner _queryPlanner;
    private IDistributedTransactionCoordinator _txCoordinator;
}

DistributedDataSourceOptions

public sealed class DistributedDataSourceOptions
{
    // Timeouts
    public int DefaultPerShardTimeoutMs { get; set; } = 30_000;
    public int DefaultReadDeadlineMs { get; set; } = 60_000;
    public int DisposeDrainTimeoutMs { get; set; } = 5_000;

    // Parallelism
    public int MaxScatterParallelism { get; set; } // Default: ProcessorCount
    public int MaxFanOutParallelism { get; set; }  // Default: ProcessorCount

    // Lifecycle
    public bool EagerOpenShards { get; set; } = true;

    // Placement
    public UnmappedEntityPolicy UnmappedPolicy { get; set; }
    public double MinimumHealthyShardRatio { get; set; } = 0.5;

    // Scatter policy
    public ScatterFailurePolicy ScatterFailurePolicy { get; set; }

    // Security
    public SecurityOptions Security { get; set; }

    // Performance (Phase 14)
    public PerformanceOptions Performance { get; set; }
}

UnmappedEntityPolicy

PolicyDescription
RejectUnmappedFail loudly on unmapped entities (default for dev)
BroadcastSend to all shards
RouteToDefaultRoute to configured default shard

DistributionPlan

public class DistributionPlan
{
    public static DistributionPlan Empty { get; }

    public string PlanId { get; set; }
    public string PlanName { get; set; }
    public DateTime CreatedAt { get; set; }

    // Entity → placement mapping
    public List<EntityPlacement> Placements { get; set; }

    // Shard definitions
    public List<ShardDefinition> Shards { get; set; }
}

Building a Plan

var plan = new DistributionPlan
{
    Placements = new List<EntityPlacement>
    {
        new EntityPlacement
        {
            EntityName = "Customers",
            Placement = PlacementType.Sharded,
            ShardKey = "CustomerId",
            ShardIds = new[] { "shard-a", "shard-b" }
        },
        new EntityPlacement
        {
            EntityName = "Products",
            Placement = PlacementType.Replicated,
            ShardIds = new[] { "shard-a", "shard-b", "shard-c" }
        }
    }
};

Placement Types

PlacementReadWriteUse Case
Sharded1 shard (by key)1 shardLarge tables, customer data
ReplicatedAny shardAll shardsReference data, lookup tables
PartitionedBroadcast queryBy partition keyTime-series data
GlobalPrimary shardPrimary shardConfiguration, small shared tables

Shard Routing

// Placement resolver maps entity + key → shard(s)
var (shardIds, placementType) = _resolver.Resolve("Customers", filters);

// Router selects specific healthy shard for execution
var targetShard = _router.RouteRead(shardIds, placementType);

// Routing hooks for custom logic
distributed.RoutingHook = new CustomShardRoutingHook();

DistributionMode Enum

public enum DistributionMode
{
    Routed    = 0,  // Entire entity on one shard, point reads/writes
    Sharded   = 1,  // Row-level sharding via partition function, scatter reads
    Replicated = 2, // Entity on every shard, fan-out writes, any-shard reads
    Broadcast = 3   // Replicated with closest-healthy-shard read preference
}

DistributedExecutionContext

public class DistributedExecutionContext
{
    // Per-operation execution context
    public string OperationId { get; set; }
    public Dictionary<string, object> ContextData { get; set; }
    public CancellationToken Token { get; set; }
}

IDistributedDataSource Interface

public interface IDistributedDataSource : IDataSource
{
    DistributionPlan DistributionPlan { get; }
    IReadOnlyDictionary<string, IProxyCluster> Shards { get; }
    Task<TransactionToken> BeginTransactionAsync(string entityName, List<string> shardIds);
}

Distributed Reads

Read TypeBehavior
Single-shardKey-based lookup routes to exactly one shard
ScatterRead from all relevant shards, merge results
ReplicatedRead from nearest healthy replica
Broadcast-joinJoin across shards with broadcast hashing
// Single-shard
var customer = distributed.GetEntity("Customers",
    new List<AppFilter> { new AppFilter { FieldName = "CustomerId",
        Operator = "=", FilterValue = "123" } });

// Scatter (auto-detects sharded placement)
var allActive = distributed.GetEntity("Orders",
    new List<AppFilter> { new AppFilter { FieldName = "Status",
        Operator = "=", FilterValue = "Active" } });

Distributed Writes

Write TypeBehavior
RoutedWrite to specific shard by key
BroadcastWrite to all relevant shards
Fan-outParallel writes with result aggregation
var result = distributed.InsertEntity("Orders", new
{
    OrderId = Guid.NewGuid(),
    CustomerId = "123", // routing key
    Amount = 149.99m
});

if (result.Flag != Errors.Ok)
    throw new InvalidOperationException(result.Message);

Transactions

public interface IDistributedTransactionCoordinator
{
    Task<TransactionToken> BeginAsync(string entityName, List<string> shardIds);
    Task PrepareAsync(TransactionToken token);
    Task CommitAsync(TransactionToken token);
    Task RollbackAsync(TransactionToken token);
}

// Usage
using var tx = await distributed.BeginTransactionAsync("Orders");
try
{
    distributed.InsertEntity("Orders", order);
    await tx.CommitAsync();
}
catch
{
    await tx.RollbackAsync();
    throw;
}

Resilience

// Scatter failure policy
public enum ScatterFailurePolicy
{
    FailFast,           // Abort on first failure
    PartialResults,     // Return partial results ≥ MinimumHealthyShardRatio
    FullResultsOrFail   // All shards must succeed
}

var options = new DistributedDataSourceOptions
{
    MinimumHealthyShardRatio = 0.5,  // 50% healthy shards required
    ScatterFailurePolicy = ScatterFailurePolicy.PartialResults
};

Capacity Controls (Phase 14)

var options = new DistributedDataSourceOptions
{
    Performance = new PerformanceOptions
    {
        EnableCapacityGates           = true,
        MaxConcurrentDistributedCalls = 64,
        DistributedPermitWait         = TimeSpan.FromMilliseconds(500),
        MaxConcurrentCallsPerShard    = 16,
        ShardPermitWait               = TimeSpan.FromMilliseconds(300),
        ShardRateLimitPerSecond       = 120,
        ShardRateLimitBurst           = 240,
        AdaptiveDeadlineFactor        = 1.3,
        MinAdaptiveDeadlineMs         = 250,
        MaxAdaptiveDeadlineMs         = 8000,
        EnableHotShardReadShedding    = true
    }
};

Overload is rejected early with BackpressureException instead of hidden latency growth.

Events

EventDescription
OnShardSelectedRouting telemetry
OnPlacementViolationPlan violations or invalid placement
OnShardDownShard marked unhealthy
OnShardRestoredShard restored to healthy
OnDegradedModeHealthy ratio below threshold
OnPartialReplicationFailureSome replicas failed
OnPartialBroadcastBroadcast partially succeeded
OnBackpressureCapacity gate rejection
OnPlanChangedDistribution plan updated

Usage Examples

Basic Setup

var shards = new Dictionary<string, IProxyCluster>
{
    ["shard-a"] = shardACluster,
    ["shard-b"] = shardBCluster,
    ["shard-c"] = shardCCluster
};

var plan = DistributionPlanBuilder.Create()
    .Shard("Customers", on: "CustomerId",
        across: new[] { "shard-a", "shard-b" })
    .Replicate("Products",
        across: new[] { "shard-a", "shard-b", "shard-c" })
    .Build();

var distributed = new DistributedDataSource(
    editor, shards, plan, options);

distributed.Openconnection();

Backpressure Handling

try
{
    var rows = distributed.GetEntity("Orders", null);
}
catch (BackpressureException bp)
{
    Console.WriteLine($"Retry after {bp.RetryAfter.TotalMilliseconds}ms");
}

Monitoring

distributed.OnShardDown += (s, e) =>
    logger.LogWarning($"Shard down: {e.ShardId}");

distributed.OnDegradedMode += (s, e) =>
    logger.LogWarning($"Degraded. Healthy ratio: {e.HealthyRatio:F2}");

distributed.OnPlacementViolation += (s, e) =>
    logger.LogError($"Placement violation: {e.EntityName}");

Full API Reference

IDistributedDataSource — Complete Interface

public interface IDistributedDataSource : IDataSource, IDisposable
{
    DistributionPlan DistributionPlan { get; }
    IReadOnlyDictionary<string, IProxyCluster> Shards { get; }
    void ApplyDistributionPlan(DistributionPlan plan);
    
    event EventHandler<ShardSelectedEventArgs> OnShardSelected;
    event EventHandler<PlacementViolationEventArgs> OnPlacementViolation;
    event EventHandler<ReshardEventArgs> OnReshardStarted;
    event EventHandler<ReshardEventArgs> OnReshardCompleted;
    event EventHandler<ReshardProgressEventArgs> OnReshardProgress;
    event EventHandler<PartialReplicationFailureEventArgs> OnPartialReplicationFailure;
    event EventHandler<TransactionInDoubtEventArgs> OnTransactionInDoubt;
    event EventHandler<ShardDownEventArgs> OnShardDown;
    event EventHandler<ShardRestoredEventArgs> OnShardRestored;
    event EventHandler<DegradedModeEventArgs> OnDegradedMode;
    event EventHandler<PartialBroadcastEventArgs> OnPartialBroadcast;
}

DistributedDataSource — 16 Partial Files

FilePhaseContent
.cs01Core state: Shards, Plan, Options, executors, IDataSource identity, constructor
.IDataSource.cs01IDataSource passthrough (GetEntity, InsertEntity, etc.)
.Plan.cs02DistributionPlan management, shard-catalog validation
.Routing.cs03-05EntityPlacementResolver + ShardRouter integration
.Reads.cs06Single-shard, scatter, replicated reads
.Writes.cs07Fan-out writes, broadcast operations
.ShardInvoker.cs08Low-level shard invocation with retry and timeout
.Transactions.cs09Transaction token management
.Resilience.cs10Circuits, retries, health checks per shard
.Observability.cs11Metrics, telemetry, SLO snapshots
.Events.cs—Event wiring and fire helpers
.Lifecycle.cs—Open/Close/Dispose orchestration
.Performance.cs14Backpressure semaphores, adaptive deadlines, hot-shard shedding
.Resharding.cs15Online resharding coordination
.Schema.cs—GetEntityStructure, entities discovery
.Audit.cs13Distributed audit event emission

Partitioning Subsystem

public interface IPartitionFunction
{
    string Name { get; }
    int Resolve(PartitionInput input, int bucketCount);
}

public struct PartitionInput
{
    public string EntityName { get; set; }
    public object[] KeyValues { get; set; }
    public string PartitionKeyField { get; set; }
    public static PartitionInput ForEntity(string entity, params object[] keys);
}

// 4 built-in partition functions:
public class HashPartitionFunction : IPartitionFunction;       // Default
public class RangePartitionFunction : IPartitionFunction;      // Range-based
public class ListPartitionFunction : IPartitionFunction;       // Explicit key → bucket
public class CompositePartitionFunction : IPartitionFunction;  // Chains multiple functions

public static class PartitionFunctionFactory
{
    public static IPartitionFunction Create(string type, object config = null);
    // type: "hash", "range", "list", "composite"
}

public static class PartitionKeyCoercer
{
    public static object Coerce(object value, Type targetType);
    // Coerces partition key to correct type for hashing
}

public static class MurmurHash3Helper
{
    public static int Hash(byte[] data, uint seed = 0);
    public static int HashString(string value, uint seed = 0);
}

Catalog Subsystem

public interface IShardCatalog
{
    IReadOnlyDictionary<string, Shard> Shards { get; }
    Shard GetShard(string shardId);
    bool TryGetShard(string shardId, out Shard shard);
    IEnumerable<Shard> GetShardsForPartitionRange(int start, int end);
}

public class Shard
{
    public string ShardId { get; set; }
    public IProxyCluster Cluster { get; set; }
    public ShardState State { get; set; }          // Active, Draining, Offline
    public int SlotStart { get; set; }             // Hash slot range start
    public int SlotEnd { get; set; }               // Hash slot range end
    public DateTime AddedAtUtc { get; set; }
    public Dictionary<string, double> Metrics { get; set; }
}

public class ShardCatalog : IShardCatalog
{
    public void AddShard(Shard shard);
    public bool RemoveShard(string shardId);
    public void UpdateShardState(string shardId, ShardState state);
}

public class ShardCatalog.Persistence.cs
{
    public Task SaveAsync(string path);
    public Task LoadAsync(string path);
}
public enum ShardState { Active, Draining, Offline }

Routing Subsystem

public interface IShardRouter
{
    RoutingDecision RouteRead(string entityName, List<AppFilter> filters,
        DistributionPlan plan);
    RoutingDecision RouteWrite(string entityName, object entity,
        DistributionPlan plan);
}

public class RoutingDecision
{
    public List<string> TargetShardIds { get; set; }
    public PlacementType PlacementType { get; set; }
    public bool IsBroadcast { get; set; }
    public string PrimaryShardId { get; set; }
    public string PartitionKey { get; set; }
}

public class ShardRouter : IShardRouter { /* uses ShardCatalog + PlacementResolver */ }

// Key extraction (.KeyExtraction partial)
public class ShardRouter.KeyExtraction.cs   // Extracts partition key from filters/entity
// Dual-write (.DualWrite partial)
public class ShardRouter.DualWrite.cs       // Dual-write routing during resharding

public interface IShardRoutingHook
{
    RoutingDecision OnRouteRead(RoutingDecision decision, string entityName);
    RoutingDecision OnRouteWrite(RoutingDecision decision, string entityName, object entity);
}
public class NullShardRoutingHook : IShardRoutingHook;   // Pass-through default

public class ShardRoutingException : Exception
{
    public string EntityName { get; }
    public PlacementType Placement { get; }
    public ShardRoutingException(string message, string entityName, PlacementType placement);
}

Execution Subsystem

public interface IDistributedReadExecutor
{
    Task<IEnumerable<object>> ExecuteSingleShardAsync(
        string entityName, List<AppFilter> filters, string shardId, CancellationToken ct);
    Task<IEnumerable<object>> ExecuteScatterAsync(
        string entityName, List<AppFilter> filters, List<string> shardIds, CancellationToken ct);
    Task<IEnumerable<object>> ExecuteReplicatedReadAsync(
        string entityName, List<AppFilter> filters, List<string> shardIds, CancellationToken ct);
}

public class DistributedReadExecutor : IDistributedReadExecutor { /* 4 partials */ }
    // .SingleShard  — single-shard with retry/failover
    // .Scatter     — parallel scatter with degree-of-parallelism cap
    // .Replicated  — nearest-healthy-replica selection

public class DistributedWriteExecutor
{
    public Task<IErrorsInfo> ExecuteRoutedAsync(
        string entityName, object entity, string shardId, CancellationToken ct);
    public Task<IErrorsInfo> ExecuteBroadcastAsync(
        string entityName, object entity, List<string> shardIds, CancellationToken ct);
    public Task<IErrorsInfo> ExecuteFanOutAsync(
        string entityName, object entity, List<string> shardIds, CancellationToken ct);
}

public class BasicResultMerger : IResultMerger
{
    public IEnumerable<object> Merge(IEnumerable<IEnumerable<object>> results);
    public IEnumerable<T> MergeTyped<T>(IEnumerable<IEnumerable<T>> results);
}

Query Subsystem

public interface IQueryPlanner
{
    QueryPlan Plan(string entityName, List<AppFilter> filters, DistributionPlan plan);
}

public class QueryPlan
{
    public QueryIntent Intent { get; set; }               // SingleShard, Scatter, BroadcastJoin
    public List<string> TargetShardIds { get; set; }
    public AggregateSpec Aggregate { get; set; }
    public MergeSpec Merge { get; set; }
    public bool IsSingleShard { get; }
    public bool IsScatter { get; }
}

public enum QueryIntent { SingleShard, Scatter, BroadcastJoin }

public enum AggregateKind { Count, Sum, Avg, Min, Max }

public class AggregateSpec
{
    public AggregateKind Kind { get; set; }
    public string FieldName { get; set; }
}

public class AggregateAccumulator
{
    public void Accumulate(object row);
    public void Merge(AggregateAccumulator other);
    public object FinalResult { get; }
}

public enum OrderDirection { Asc, Desc }

public class OrderBySpec
{
    public string FieldName { get; set; }
    public OrderDirection Direction { get; set; }
}

public class MergeSpec
{
    public bool Distinct { get; set; }
    public List<OrderBySpec> OrderBy { get; set; }
    public int? Top { get; set; }
}

public enum MergeOperation { Union, Concat, Intersect }

public interface IQueryAwareResultMerger
{
    IEnumerable<object> Merge(IEnumerable<IEnumerable<object>> shardResults,
        MergeSpec spec, CancellationToken ct = default);
}

public class QueryAwareResultMerger : IQueryAwareResultMerger
{
    // .Sorting  — merge-sort from sorted shard results
    // .Grouping — group-by aggregation across shards
}

public class QueryPlanner : IQueryPlanner { /* resolves Plan from filters + placement */ }

public class BroadcastJoinRewriter
{
    public QueryPlan RewriteForBroadcastJoin(QueryPlan plan, DistributionPlan distPlan);
}

public class RowValueExtractor
{
    public static object GetValue(object row, string fieldName);
}

Transactions Subsystem

public interface IDistributedTransactionCoordinator
{
    Task<TransactionToken> BeginAsync(string entityName, List<string> shardIds,
        TransactionStrategy strategy = TransactionStrategy.SingleShard);
    Task PrepareAsync(TransactionToken token);
    Task CommitAsync(TransactionToken token);
    Task RollbackAsync(TransactionToken token);
}

public enum TransactionStrategy { SingleShard, TwoPhaseCommit, Saga }

public class DistributedTransactionCoordinator : IDistributedTransactionCoordinator
{
    // .SingleShard     — begin on one shard, no coordination needed
    // .TwoPhaseCommit  — 2PC: prepare all → commit all (or rollback)
    // .Saga            — compensating-saga steps on abort
}

public class TransactionToken : IDisposable
{
    public string TokenId { get; }
    public string EntityName { get; }
    public DistributedTransactionStatus Status { get; }

    public Task CommitAsync();
    public Task RollbackAsync();
    public void Dispose();
}

public class DistributedTransactionScope : IDisposable { /* convenience wrapper */ }

public enum DistributedTransactionStatus
{
    None, Active, Preparing, Prepared, Committing, Committed,
    RollingBack, RolledBack, InDoubt, TimedOut
}

public enum TransactionLogKind { Prepare, Commit, Rollback, Compensate }

public class TransactionLogEntry
{
    public string TokenId { get; set; }
    public TransactionLogKind Kind { get; set; }
    public string ShardId { get; set; }
    public DateTime TimestampUtc { get; set; }
    public string EntityName { get; set; }
}

public interface IDistributedTransactionLog
{
    Task AppendAsync(TransactionLogEntry entry);
    Task<IReadOnlyList<TransactionLogEntry>> GetEntriesAsync(string tokenId);
    Task ClearAsync(string tokenId);
}

public class InMemoryTransactionLog : IDistributedTransactionLog;
public class FileTransactionLog : IDistributedTransactionLog;

public class TransactionDecisionResolver
{
    public DistributedTransactionStatus Resolve(
        IReadOnlyList<TransactionLogEntry> log);
}

public class SagaStep
{
    public string StepName { get; set; }
    public Func<Task> ExecuteAsync { get; set; }
    public Func<Task> CompensateAsync { get; set; }
    public bool IsCritical { get; set; }
}

Placement Subsystem

public class EntityPlacementResolver
{
    public PlacementResolution Resolve(string entityName, List<AppFilter> filters,
        DistributionPlan plan);
    public PlacementResolution ResolveForWrite(string entityName, object entity,
        DistributionPlan plan);
}

public enum PlacementMatchKind { Exact, Wildcard, Default }

public class PlacementResolution
{
    public PlacementMatchKind MatchKind { get; set; }
    public PlacementType PlacementType { get; set; }
    public List<string> ShardIds { get; set; }
    public string PartitionKeyField { get; set; }
    public bool IsSharded { get; }
    public bool IsReplicated { get; }
}

public class EntityPlacementMap
{
    public Dictionary<string, List<string>> EntityToShards { get; set; }
    public EntityPlacementMap(DistributionPlan plan);
    public bool TryGetShards(string entityName, out List<string> shardIds);
}

All Event Args

Event Args ClassKey Properties
ShardSelectedEventArgsEntityName, ShardId, Filters, PlacementType
PlacementViolationEventArgsEntityName, Violation, PlanId
ReshardEventArgsPlanId, OldPlanId, Succeeded, Error, StartedAtUtc
ReshardProgressEventArgsPlanId, PercentComplete, EntitiesCopied, EntitiesTotal
PartialReplicationFailureEventArgsEntityName, SuccessfulShards, FailedShards, QuorumMet
PartialBroadcastEventArgsEntityName, ExcludedShards, Reason
ShardDownEventArgsShardId, Reason, DetectedAtUtc
ShardRestoredEventArgsShardId, DowntimeDuration, RestoredAtUtc
DegradedModeEventArgsHealthyRatio, HealthyShardCount, TotalShardCount
TransactionInDoubtEventArgsTokenId, ShardId, PreparedShards, FailedShards

Audit Subsystem

public enum DistributedAuditEventKind
{
    ShardRouted, ShardFailed, PlacementViolation,
    TransactionStarted, TransactionPrepared, TransactionCommitted, TransactionRolledBack,
    ReshardStarted, ReshardProgress, ReshardCompleted,
    ShardDown, ShardRestored, DegradedMode, BackpressureRejected
}

public class DistributedAuditEvent
{
    public DistributedAuditEventKind Kind { get; set; }
    public string EntityName { get; set; }
    public string ShardId { get; set; }
    public DateTime TimestampUtc { get; set; }
    public Dictionary<string, object> Metadata { get; set; }
}

public interface IDistributedAuditSink
{
    void Record(DistributedAuditEvent auditEvent);
}

public class FileDistributedAuditSink : IDistributedAuditSink;

Security

public interface IDistributedAccessPolicy
{
    bool CanAccessShard(string entityName, string shardId);
    bool CanAccessEntity(string entityName);
}
// Set via DistributedDataSourceOptions.Security

Complete Enums

EnumValues
DistributionModeRouted, Sharded, Replicated, Broadcast
PlacementTypeSharded, Replicated, Partitioned, Global
UnmappedEntityPolicyRejectUnmapped, Broadcast, RouteToDefault
ScatterFailurePolicyFailFast, PartialResults, FullResultsOrFail
ShardStateActive, Draining, Offline
TransactionStrategySingleShard, TwoPhaseCommit, Saga
DistributedTransactionStatusNone, Active, Preparing, Prepared, Committing, Committed, RollingBack, RolledBack, InDoubt, TimedOut
TransactionLogKindPrepare, Commit, Rollback, Compensate
DistributedAuditEventKindShardRouted, ShardFailed, PlacementViolation, TransactionStarted, TransactionPrepared, TransactionCommitted, TransactionRolledBack, ReshardStarted, ReshardProgress, ReshardCompleted, ShardDown, ShardRestored, DegradedMode, BackpressureRejected
PlacementMatchKindExact, Wildcard, Default
QueryIntentSingleShard, Scatter, BroadcastJoin
AggregateKindCount, Sum, Avg, Min, Max
OrderDirectionAsc, Desc
MergeOperationUnion, Concat, Intersect

Source File Map (100+ files)

CategoryFileContent
CoreIDistributedDataSource.csInterface: 11 events, DistributionPlan, Shards, ApplyDistributionPlan
DistributedDataSourceOptions.csOptions: timeouts, parallelism, lifecycle, placement, scatter, security, performance
DistributedExecutionContext.csPer-operation context: OperationId, ContextData, Token
Partials.csCore state, constructor, executors wiring, IDataSource identity
.IDataSource.csIDataSource passthrough methods
.Plan.csDistributionPlan Apply/Validate
.Routing.csPlacementResolver + ShardRouter integration
.Reads.csSingle, Scatter, Replicated read dispatch
.Writes.csFan-out, Broadcast write dispatch
.ShardInvoker.csLow-level shard call with retry/timeout
.Transactions.csTransaction token factory
.Resilience.csCircuit breakers, health checks
.Observability.csMetrics, telemetry, SLO
.Events.csEvent helpers
.Lifecycle.csOpen/Close/Dispose
.Performance.csBackpressure, deadlines, shedding
.Resharding.csOnline reshard coordination
.Schema.csEntity structure discovery
.Audit.csAudit events emission
PartitioningIPartitionFunction.csInterface: Name, Resolve(PartitionInput, bucketCount)
HashPartitionFunction.csConsistent hashing via MurmurHash3
RangePartitionFunction.csRange-based sharding
ListPartitionFunction.csExplicit key → bucket
CompositePartitionFunction.csChaining multiple functions
PartitionFunctionFactory.csFactory: Create("hash"|"range"|"list"|"composite")
PartitionInput.cs / .cs / MurmurHash3Helper.csInput struct, key coercer, hash helper
CatalogIShardCatalog.csCatalog interface
ShardCatalog.csShard registry + state management
ShardCatalog.Persistence.csSave/Load catalog from file
RoutingIShardRouter.csRouter interface: RouteRead, RouteWrite
ShardRouter.csConcrete router
ShardRouter.KeyExtraction.csPartition key extraction from filters/entities
ShardRouter.DualWrite.csDual-write routing during resharding
RoutingDecision.csDecision: TargetShardIds, PlacementType, IsBroadcast
IShardRoutingHook.cs / NullShardRoutingHook.csCustom routing hook + default pass-through
ShardRoutingException.csRouting exception with entity + placement info
ExecutionIDistributedReadExecutor — DistributedReadExecutor.cs + .SingleShard + .Scatter + .Replicated4 partials: single, scatter, replicated read pipelines
DistributedWriteExecutor.csRouted, Broadcast, FanOut write pipelines
BasicResultMerger.csSimple union/concat merge
(see Query subsystem for QueryAwareResultMerger)
TransactionsIDistributedTransactionCoordinator.csInterface: BeginAsync, Prepare, Commit, Rollback
DistributedTransactionCoordinator.cs + .SingleShard + .TwoPhaseCommit + .Saga4 partials: single-shard, 2PC, Saga strategies
DistributedTransactionScope.csConvenience IDisposable wrapper
IDistributedTransactionLog.cs, InMemoryTransactionLog.cs, FileTransactionLog.csLog contract + memory + file implementations
TransactionDecisionResolver.csResolves InDoubt via log replay
TransactionLogEntry.cs, TransactionLogKind.cs, DistributedTransactionStatus.cs, TransactionStrategy.cs, SagaStep.csModel types + enums
PlacementEntityPlacementResolver.csResolve entity+filters → shard(s) + placement type
EntityPlacementMap.csEntity → shards lookup dictionary
PlacementMatchKind.csExact, Wildcard, Default
PlacementResolution.csResolution result model
QueryIQueryPlanner.csPlanner interface: Plan(entity, filters, plan)
QueryPlanner.csConcrete planner
QueryPlan.csPlan: Intent, ShardIds, Aggregate, Merge
QueryIntent.csSingleShard, Scatter, BroadcastJoin
AggregateKind.csCount, Sum, Avg, Min, Max
AggregateSpec.csSpec: Kind, FieldName
AggregateAccumulator.csPer-shard → merged accumulator
OrderBySpec.cs / OrderDirection.csOrder spec + direction enum
MergeSpec.csMerge spec: Distinct, OrderBy, Top
MergeOperation.csUnion, Concat, Intersect
IQueryAwareResultMerger.csSmart merger interface
QueryAwareResultMerger.cs + .Sorting + .Grouping3 partials: merge-sort, group-by aggregation
BroadcastJoinRewriter.csPlan rewriting for broadcast joins
RowValueExtractor.csField value extraction from object rows
EventsShardSelectedEventArgs.csEntityName, ShardId, Filters, PlacementType
PlacementViolationEventArgs.csEntityName, Violation, PlanId
ReshardEventArgs.csPlanId, OldPlanId, Succeeded, Error
ReshardProgressEventArgs.csPercentComplete, EntitiesCopied, EntitiesTotal
PartialReplicationFailureEventArgs.csSuccessfulShards, FailedShards, QuorumMet
PartialBroadcastEventArgs.csExcludedShards, Reason
TransactionInDoubtEventArgs.csTokenId, ShardId, PreparedShards, FailedShards
ShardDownEventArgs.cs / ShardRestoredEventArgs.csShardId, Reason/DowntimeDuration
DegradedModeEventArgs.csHealthyRatio, HealthyShardCount
AuditIDistributedAuditSink.csAudit sink contract: Record
DistributedAuditEventKind.cs14 audit event kinds
DistributedAuditEvent.csEvent model: Kind, EntityName, ShardId, Metadata
FileDistributedAuditSink.csFile-based audit sink
SecurityIDistributedAccessPolicy.csCanAccessShard, CanAccessEntity