Table of Contents

Class PersistenceProviderBuilder

Namespace
Excalibur.Data.Persistence
Assembly
Excalibur.Data.Abstractions.dll

Builds a composed IPersistenceProvider by stacking DelegatingPersistenceProvider decorators around an inner provider. Follows the ChatClientBuilder pattern from Microsoft.Extensions.AI.

public sealed class PersistenceProviderBuilder
Inheritance
PersistenceProviderBuilder
Inherited Members

Remarks

Decorators are applied in registration order: the first registered decorator is the outermost wrapper. This is identical to the ordering semantics of TransportSenderBuilder and HttpMessageHandlerBuilder.

Example: composing logging and retry decorators around a SQL Server provider:

var provider = new PersistenceProviderBuilder(sqlServerProvider)
    .Use(inner => new RetryPersistenceProvider(inner, retryPolicy))
    .Use(inner => new LoggingPersistenceProvider(inner, logger))
    .Build();

Constructors

PersistenceProviderBuilder(IPersistenceProvider)

Initializes a new instance of the PersistenceProviderBuilder class.

public PersistenceProviderBuilder(IPersistenceProvider innerProvider)

Parameters

innerProvider IPersistenceProvider

The native persistence provider to decorate.

Methods

Build()

Builds the composed IPersistenceProvider by applying all registered decorators.

public IPersistenceProvider Build()

Returns

IPersistenceProvider

The fully composed persistence provider.

Use(Func<IPersistenceProvider, IPersistenceProvider>)

Adds a decorator to the provider pipeline.

public PersistenceProviderBuilder Use(Func<IPersistenceProvider, IPersistenceProvider> decorator)

Parameters

decorator Func<IPersistenceProvider, IPersistenceProvider>

A factory that wraps the current provider with a decorator.

Returns

PersistenceProviderBuilder

This builder for chaining.