PersistedOperationsBuilder

Fluent configuration surface passed to UsePersistedOperations. All methods return PersistedOperationsBuilder for chaining.

Methods

MethodDefaultPurpose
UseDatabase(string connectionString)requiredPostgres connection string for the persisted-operation tables. Throws if missing.
RequirePersisted(bool require = true)trueReject inline-query requests. Set false for shadow mode.
LogNonPersistedRequests(bool log = true)falseLog every inline-query request at Information. Use during phased rollout.
AllowOperations(params string[] names)emptyOperation names that bypass enforcement. Case-sensitive.
AllowOperationsMatching(Func<string, bool>)emptyPredicate form. Useful for id => id.StartsWith("dev_").
DisableIntrospection()introspection allowedReject introspection requests. Use only for strict prod.
WithInMemoryCache(Action<CacheOptions>?)no cacheWrap storage with IMemoryCache. The default path hits the DB on every request.
UseRabbitMqInvalidation(string connectionString)no broadcasterMulti-node cache invalidation via RabbitMQ fanout. Requires WithInMemoryCache().

CacheOptions

MethodDefaultPurpose
WithTtl(TimeSpan ttl)15 minutesCache entry lifetime. Backstop only; broadcast invalidation is the primary mechanism.

Example

opts
    .UseDatabase(connectionString)
    .RequirePersisted(true)
    .LogNonPersistedRequests(true)
    .AllowOperations("playground_smoke_test")
    .AllowOperationsMatching(id => id.StartsWith("dev_"))
    .WithInMemoryCache(c => c.WithTtl(TimeSpan.FromMinutes(10)))
    .UseRabbitMqInvalidation("amqp://guest:guest@localhost:5672/");

Validation rules

The builder's Build() runs at startup and throws InvalidOperationException for inconsistent configurations. See the UsePersistedOperations validation table for every check.