Method AddInfrastructure
- Namespace
- MailFathom.Infrastructure
- Assembly
- MailFathom.Infrastructure.dll
AddInfrastructure(IServiceCollection, Func<IServiceProvider, PostgresConnectionSettings>, PostgresTextSearchConfiguration, MailAnsweringBudget)
Registers EF Core persistence, MailKit mailbox access, and application synchronization services.
public static IServiceCollection AddInfrastructure(this IServiceCollection services, Func<IServiceProvider, PostgresConnectionSettings> currentConnectionSettings, PostgresTextSearchConfiguration textSearchConfiguration, MailAnsweringBudget answeringBudget)
Parameters
servicesIServiceCollectionThe service collection.
currentConnectionSettingsFunc<IServiceProvider, PostgresConnectionSettings>Supplies where the PostgreSQL connection string and its password currently come from.
textSearchConfigurationPostgresTextSearchConfigurationThe validated PostgreSQL text search configuration the lexical index is built with.
answeringBudgetMailAnsweringBudgetThe validated ceilings one question about the mailbox is subject to.
Returns
- IServiceCollection
The service collection, for chaining.
Remarks
The settings arrive already read rather than as an IConfiguration this method reaches into, so which key
holds them stays a host decision and this assembly gains no configuration dependency. They arrive as an
accessor rather than as a value because a secret reference can be repointed by a configuration reload, and a
value captured at registration would keep authenticating with the reference the operator replaced.
The embedding stores registered here are the tables; the units of work that write vectors into them are not, and belong to AddEmailEmbeddingGeneration(IServiceCollection) for the reason that method states. A registration added here that constructor-injects an ITextEmbeddingGenerator belongs there instead, because that is the descriptor a container cannot build where no chain was declared.
A factory that asks for one optionally is the other case and stays here. Nothing validates a factory's body, so such a descriptor builds in every container and answers null where there is no generator — which is what the read path needs, because search is served by every deployment and a registration made only where a chain was declared would leave a lexical-only instance unable to resolve a search at all. SemanticEmailSearch is the one such registration.
Exceptions
- ArgumentNullException
Thrown when any argument is null.