Lyo.Config.Postgres
1.0.11
dotnet add package Lyo.Config.Postgres --version 1.0.11
NuGet\Install-Package Lyo.Config.Postgres -Version 1.0.11
<PackageReference Include="Lyo.Config.Postgres" Version="1.0.11" />
<PackageVersion Include="Lyo.Config.Postgres" Version="1.0.11" />
<PackageReference Include="Lyo.Config.Postgres" />
paket add Lyo.Config.Postgres --version 1.0.11
#r "nuget: Lyo.Config.Postgres, 1.0.11"
#:package Lyo.Config.Postgres@1.0.11
#addin nuget:?package=Lyo.Config.Postgres&version=1.0.11
#tool nuget:?package=Lyo.Config.Postgres&version=1.0.11
Lyo.Config.Postgres
PostgreSQL + EF Core implementation of Lyo.Config.IConfigStore for typed configuration definitions and per-entity bindings.
What ships
ConfigDbContext(+ConfigDbContextFactory) underDatabase/withDbSet<ConfigDefinitionEntity>,DbSet<ConfigBindingEntity>,DbSet<ConfigBindingRevisionEntity>, andDbSet<ConfigDefinitionRevisionEntity>.- Fluent-API entity configurations enforcing the uniqueness rules from
Lyo.Config: config_definitionunique on(ForEntityType, Key).config_bindingunique on(DefinitionId, ForEntityType, ForEntityId)withON DELETE CASCADEfrom the definition row.config_binding_revisionkeyed on(BindingId, Revision)monotonic 1-based revision numbers per binding.config_definition_revisionkeyed on(DefinitionId, Revision)monotonic 1-based metadata snapshots per definition. EverySaveDefinitionAsyncappends a row.IsEncryptedon the definition plusencrypted_default_value/encrypted_valuebyteacolumns. Encryption runs only whenIConfigValueEncryptionServiceis registered (Config.Api / TestApi). Toggling Encrypted rewrites stored defaults and all binding revisions. TestGateway does not register encryption; it writes throughConfigApiStoreHTTP to TestApi.PostgresConfigStore, the singletonIConfigStoreimplementation backed by anIDbContextFactory<ConfigDbContext>. It also implementsLyo.Health.IHealthso the container can be probed for relational connectivity.PostgresConfigOptions(SectionName = "PostgresConfig",Schema = "config",ConnectionString,EnableAutoMigrations).- Migrations under
Migrations/(InitialCreatebaseline) using theconfigschema for the EF migrations history table.
DI registration (Extensions)
All entry points are exposed as IServiceCollection extensions:
| Entry point | What it does |
|---|---|
AddConfigDbContextFactory(Action<PostgresConfigOptions>) |
Registers IOptions<PostgresConfigOptions>, AddPostgresMigrations<ConfigDbContext, PostgresConfigOptions>(), and IDbContextFactory<ConfigDbContext> (UseNpgsql + migrations history under the configured schema). DbContext only, does not register IConfigStore. |
AddConfigDbContextFactoryFromConfiguration(IConfiguration, string sectionName = PostgresConfigOptions.SectionName) |
Same as above; binds from the configuration section (default "PostgresConfig"). |
AddConfigDbContextFactory(PostgresConfigOptions options) |
Same as above with a pre-built options instance. |
AddPostgresConfigStore(Action<PostgresConfigOptions>) |
Calls AddConfigDbContextFactory(...) then registers IConfigStore → singleton PostgresConfigStore. |
AddPostgresConfigStoreFromConfiguration(IConfiguration, string sectionName = PostgresConfigOptions.SectionName) |
Same as above; binds from configuration. |
AddPostgresConfigStore(PostgresConfigOptions options) |
Same as above with a pre-built options instance, for tests / integration harnesses. Resolves optional IConfigValueEncryptionService from DI (null on workbench hosts). |
AddConfigValueEncryption(keyName = ConfigQueryRoutes.EncryptionKeyName) |
Registers IConfigValueEncryptionService using a keyed IEncryptionService. Call on API hosts only. |
AddConfigQueryServices() |
Registers query/CRUD-read/export services for ConfigDbContext. Call on API hosts before MapConfigQueryEndpoints. |
MapConfigQueryEndpoints() |
Maps query/get/export for Config/Definition and Config/Binding. Writes stay on IConfigStore. DeniedSelectFields hide DefaultValueJson and EncryptedDefaultValue. |
PostgresConfigOptions.ConnectionString is validated (non-empty) by all entry points. The EnableAutoMigrations flag is consumed by AddPostgresMigrations<>. See
Lyo.Postgres to gate the hosted-startup migration runner.
Runtime expectations
PostgresConfigStore opens a fresh ConfigDbContext per call via the registered IDbContextFactory<ConfigDbContext>, so a singleton is safe under concurrent load. SaveDefinitionAsync upserts config_definition and appends config_definition_revision. When IsEncrypted flips, existing defaults and all config_binding_revision rows are rewritten to ciphertext or back to JSON. SaveBindingAsync appends config_binding_revision inside the same SaveChangesAsync. When IsEncrypted is set, plaintext JSON columns are cleared and ciphertext is stored in bytea. Public LoadConfigAsync decrypts so apps get usable config.
Tenancy
Bindings (and their revisions) carry a nullable tenant_id column; definitions do not. Schema is deployment-global. The config_binding unique constraint includes
tenant_id, so the same definition can be bound per tenant without collision. Filtered tenant indexes (ix_config_binding_tenant, ix_config_binding_revision_tenant)
back lookups.
IConfigStore binding methods (not definition methods) accept an explicit Guid? tenantId and run it through TenancyResolver.Resolve using the policy configured in
PostgresConfigOptions.Tenancy (inheriting from EntityRefOptions.Mode when unset):
SystemOnly. Bindings are persisted withtenant_id = NULL.SingleTenantDefault(default), caller value, falling back toTenancy.DefaultTenantIdthenEntityRefOptions.DefaultTenantId.MultiTenantStrict. Caller must supply a non-emptytenantIdor the store throws.
See Lyo.EntityReference.Postgres for the policy matrix.
{
"PostgresConfig": {
"ConnectionString": "Host=localhost;Database=config;...",
"Tenancy": { "Mode": "MultiTenantStrict" }
}
}
Dependencies
Generated from ProjectReference / PackageReference (same model as docs/Lyo.ProjectGraph.html).
Lyo.Api(direct, lyo)Lyo.Api.Export(direct, lyo)Lyo.Config(direct, lyo)Lyo.Encryption(direct, lyo)Lyo.EntityReference.Models(direct, lyo)Lyo.EntityReference.Postgres(direct, lyo)Lyo.Health(direct, lyo)Lyo.Postgres(direct, lyo)Microsoft.EntityFrameworkCore10.0.5(direct, microsoft)Microsoft.EntityFrameworkCore.Design10.0.5(direct, microsoft)Microsoft.Extensions.Configuration.Binder10.0.5(direct, microsoft)Lyo.Api.Models(transitive, lyo)Lyo.Cache(transitive, lyo)Lyo.Common(transitive, lyo)Lyo.Compression(transitive, lyo)Lyo.DateAndTime(transitive, lyo)Lyo.Diagnostic(transitive, lyo)Lyo.Diagnostic.AspNetCore(transitive, lyo)Lyo.Diff(transitive, lyo)Lyo.Exceptions(transitive, lyo)Lyo.Formatter(transitive, lyo)Lyo.Hashing(transitive, lyo)Lyo.KeyStore(transitive, lyo)Lyo.Metrics(transitive, lyo)Lyo.PackageMetadata(transitive, lyo)Lyo.Query(transitive, lyo)Lyo.Query.Models(transitive, lyo)Lyo.Result(transitive, lyo)Lyo.Streams(transitive, lyo)Lyo.Validation(transitive, lyo)BouncyCastle.Cryptography2.6.2(transitive, third-party, netstandard2.0)DynamicExpresso.Core2.19.3(transitive, third-party)EasyCompressor2.1.0(transitive, third-party)Konscious.Security.Cryptography.Argon21.3.1(transitive, third-party)Microsoft.AspNetCore.OpenApi10.0.5(transitive, microsoft)Microsoft.Bcl.AsyncInterfaces10.0.5(transitive, microsoft, netstandard2.0)Microsoft.EntityFrameworkCore.Analyzers10.0.5(transitive, microsoft)Microsoft.EntityFrameworkCore.Relational10.0.5(transitive, microsoft)Microsoft.Extensions.Caching.Memory10.0.5(transitive, microsoft)Microsoft.Extensions.DependencyInjection10.0.5(transitive, microsoft)Microsoft.Extensions.DependencyInjection.Abstractions10.0.5(transitive, microsoft, net10.0, netstandard2.0)Microsoft.Extensions.Hosting.Abstractions10.0.5(transitive, microsoft)Microsoft.Extensions.Logging.Abstractions10.0.5(transitive, microsoft)Microsoft.Extensions.Options10.0.5(transitive, microsoft)Microsoft.Extensions.Options.ConfigurationExtensions10.0.5(transitive, microsoft)Npgsql.EntityFrameworkCore.PostgreSQL10.0.3(transitive, third-party)SmartFormat.NET3.6.1(transitive, third-party)System.Buffers4.6.1(transitive, microsoft, netstandard2.0)System.ComponentModel.Annotations5.0.0(transitive, microsoft)System.IO.Hashing10.0.5(transitive, microsoft, net10.0)System.Memory4.6.3(transitive, microsoft, netstandard2.0)System.Text.Json10.0.5(transitive, microsoft, netstandard2.0)System.Threading.Tasks.Extensions4.6.3(transitive, microsoft, netstandard2.0)
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Lyo.Api (>= 1.0.11)
- Lyo.Api.Export (>= 1.0.11)
- Lyo.Config (>= 1.0.11)
- Lyo.Encryption (>= 1.0.11)
- Lyo.EntityReference.Models (>= 1.0.11)
- Lyo.EntityReference.Postgres (>= 1.0.11)
- Lyo.Health (>= 1.0.11)
- Lyo.Postgres (>= 1.0.11)
- Microsoft.EntityFrameworkCore (>= 10.0.5)
- Microsoft.Extensions.Configuration.Binder (>= 10.0.5)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Lyo.Config.Postgres:
| Package | Downloads |
|---|---|
|
Lyo.Config.Api
Central HTTP API exposing Lyo.Config PostgreSQL-backed IConfigStore for microservices (polling-friendly ETags). Embed via AddConfigApi / MapConfigApiEndpoints. |
GitHub repositories
This package is not used by any popular GitHub repositories.