Class DeploymentSecretService
Service for managing deployment-global secrets loaded by servers at startup. Uses a compiled query for reads and a raw SQL upsert for writes.
public sealed class DeploymentSecretService : BaseService<DeploymentSecretEntity>, IDeploymentSecretService
- Inheritance
-
DeploymentSecretService
- Implements
- Inherited Members
Constructors
DeploymentSecretService(INpgsqlDbContextFactory)
Initializes a new instance of DeploymentSecretService.
public DeploymentSecretService(INpgsqlDbContextFactory dbContextFactory)
Parameters
dbContextFactoryINpgsqlDbContextFactoryDbContext factory for creating contexts.
Exceptions
- ArgumentNullException
Thrown when dbContextFactory is null.
Methods
FetchAsync(string, CancellationToken)
Fetches a secret value by its key.
public Task<DatabaseResult<string>> FetchAsync(string key, CancellationToken cancellationToken = default)
Parameters
keystringThe logical key identifying the secret.
cancellationTokenCancellationTokenCancellation token.
Returns
- Task<DatabaseResult<string>>
A DatabaseResult<T> containing the secret value if found; otherwise a failure with ENTITY_NOT_FOUND.
UpsertAsync(string, string, CancellationToken)
Inserts or updates a deployment secret.
On insert, a new row is created with the current timestamp.
On update, the value and updated_at are refreshed.
public Task<DatabaseResult> UpsertAsync(string key, string value, CancellationToken cancellationToken = default)
Parameters
keystringThe logical key identifying the secret.
valuestringThe secret value to store.
cancellationTokenCancellationTokenCancellation token.
Returns
- Task<DatabaseResult>
A DatabaseResult describing the outcome.