arolariu.Backend.Common.Configuration
arolariu.Backend.Common
arolariu.Backend.Common.Configuration Namespace
Classes
ConfigProxyClient Class
HTTP client implementation for the exp config proxy, backed by the simplified /api/v1 config endpoint.
public sealed class ConfigProxyClient : arolariu.Backend.Common.Configuration.IConfigProxyClient
Inheritance System.Object 🡒 ConfigProxyClient
Implements IConfigProxyClient
Remarks
All methods are stateless: each call issues exactly one HTTP GET request and deserialises the JSON response. Retry, caching, and circuit-breaking policies belong in the infrastructure layer that wraps this broker.
Constructors
ConfigProxyClient(HttpClient, ILogger<ConfigProxyClient>) Constructor
HTTP client implementation for the exp config proxy, backed by the simplified /api/v1 config endpoint.
public ConfigProxyClient(System.Net.Http.HttpClient httpClient, Microsoft.Extensions.Logging.ILogger<arolariu.Backend.Common.Configuration.ConfigProxyClient> logger);
Parameters
httpClient System.Net.Http.HttpClient
logger Microsoft.Extensions.Logging.ILogger<ConfigProxyClient>
Remarks
All methods are stateless: each call issues exactly one HTTP GET request and deserialises the JSON response. Retry, caching, and circuit-breaking policies belong in the infrastructure layer that wraps this broker.
Methods
ConfigProxyClient.GetConfigValueAsync(string, string, CancellationToken) Method
Fetches a single indexed configuration value by name.
public System.Threading.Tasks.Task<arolariu.Backend.Common.Configuration.ConfigValueResponse?> GetConfigValueAsync(string name, string? label=null, System.Threading.CancellationToken ct=default(System.Threading.CancellationToken));
Parameters
name System.String
The canonical configuration key name (for example: Endpoints:Service:Api).
label System.String
Optional Azure App Configuration label (for example: PRODUCTION). When provided the label is forwarded to the exp service.
ct System.Threading.CancellationToken
Cancellation token for the operation.
Implements GetConfigValueAsync(string, string, CancellationToken)
Returns
System.Threading.Tasks.Task<ConfigValueResponse>
The typed config value response, or null when the request fails or the service is unavailable.
ConfigRefreshHostedService Class
Background service that periodically refreshes configuration values from the exp proxy by fetching each config key individually.
public sealed class ConfigRefreshHostedService : Microsoft.Extensions.Hosting.BackgroundService
Inheritance System.Object 🡒 Microsoft.Extensions.Hosting.BackgroundService 🡒 ConfigRefreshHostedService
Remarks
On each cycle the service:
- Waits for the configured refresh interval (default 300 seconds, minimum 60 seconds).
- Fetches each of the ConfigKeys individually via GetConfigValueAsync(string, string, CancellationToken).
- Swaps the AzureOptions snapshot via Microsoft.Extensions.Options.IOptionsMonitorCache<>.
If the refresh fails the error is logged and the previous snapshot is preserved.
Constructors
ConfigRefreshHostedService(IConfigProxyClient, FeatureSnapshotCache, IOptionsMonitor<AzureOptions>, IOptionsMonitorCache<AzureOptions>, ILogger<ConfigRefreshHostedService>) Constructor
Background service that periodically refreshes configuration values from the exp proxy by fetching each config key individually.
public ConfigRefreshHostedService(arolariu.Backend.Common.Configuration.IConfigProxyClient proxyClient, arolariu.Backend.Common.Configuration.FeatureSnapshotCache featureSnapshotCache, Microsoft.Extensions.Options.IOptionsMonitor<arolariu.Backend.Common.Options.AzureOptions> optionsMonitor, Microsoft.Extensions.Options.IOptionsMonitorCache<arolariu.Backend.Common.Options.AzureOptions> optionsCache, Microsoft.Extensions.Logging.ILogger<arolariu.Backend.Common.Configuration.ConfigRefreshHostedService> logger);
Parameters
proxyClient IConfigProxyClient
The config proxy client used to fetch individual config values.
featureSnapshotCache FeatureSnapshotCache
The in-memory feature flag snapshot cache (retained for future use).
optionsMonitor Microsoft.Extensions.Options.IOptionsMonitor<AzureOptions>
The options monitor for reading the current AzureOptions snapshot.
optionsCache Microsoft.Extensions.Options.IOptionsMonitorCache<AzureOptions>
The options cache used to atomically swap refreshed option snapshots.
logger Microsoft.Extensions.Logging.ILogger<ConfigRefreshHostedService>
The logger for recording refresh events and errors.
Remarks
On each cycle the service:
- Waits for the configured refresh interval (default 300 seconds, minimum 60 seconds).
- Fetches each of the ConfigKeys individually via GetConfigValueAsync(string, string, CancellationToken).
- Swaps the AzureOptions snapshot via Microsoft.Extensions.Options.IOptionsMonitorCache<>.
If the refresh fails the error is logged and the previous snapshot is preserved.
Fields
ConfigRefreshHostedService.ConfigKeys Field
The canonical config key names fetched on each refresh cycle.
private static readonly string[] ConfigKeys;
Field Value
ConfigRefreshHostedService.DefaultRefreshIntervalSeconds Field
Default refresh interval in seconds.
private const int DefaultRefreshIntervalSeconds = 300;
Field Value
ConfigValueResponse Class
Represents the typed response returned by GET /api/v1/config?name={config-key}.
public sealed class ConfigValueResponse
Inheritance System.Object 🡒 ConfigValueResponse
Remarks
Unlike the build-time and run-time endpoints, the config endpoint resolves one indexed configuration value at a time. The response includes documentation metadata so callers can understand where the value belongs and which targets are allowed to request it.
Properties
ConfigValueResponse.AvailableForTargets Property
Gets the caller targets that may request this value from exp.
public System.Collections.Generic.IReadOnlyList<string> AvailableForTargets { get; init; }
Property Value
System.Collections.Generic.IReadOnlyList<System.String>
ConfigValueResponse.AvailableInDocuments Property
Gets the build-time and run-time documents that contain this value.
public System.Collections.Generic.IReadOnlyList<string> AvailableInDocuments { get; init; }
Property Value
System.Collections.Generic.IReadOnlyList<System.String>
ConfigValueResponse.Description Property
Gets the short human-readable description of the config value.
public string Description { get; init; }
Property Value
ConfigValueResponse.FetchedAt Property
Gets the UTC timestamp at which the exp service resolved this value.
public System.DateTimeOffset FetchedAt { get; init; }
Property Value
ConfigValueResponse.Name Property
Gets the canonical configuration key name, for example Endpoints:Service:Api.
public string Name { get; init; }
Property Value
ConfigValueResponse.RefreshIntervalSeconds Property
Gets the server-recommended refresh interval in seconds.
public int RefreshIntervalSeconds { get; init; }
Property Value
ConfigValueResponse.RequiredInDocuments Property
Gets the documents where this value is required rather than optional.
public System.Collections.Generic.IReadOnlyList<string> RequiredInDocuments { get; init; }
Property Value
System.Collections.Generic.IReadOnlyList<System.String>
ConfigValueResponse.Usage Property
Gets the server-authored usage guidance for the config value.
public string Usage { get; init; }
Property Value
ConfigValueResponse.Value Property
Gets the resolved configuration value for the requested key.
public string Value { get; init; }
Property Value
FeatureSnapshotCache Class
Thread-safe in-memory cache for the API feature flag snapshot sourced from the exp service.
public sealed class FeatureSnapshotCache
Inheritance System.Object 🡒 FeatureSnapshotCache
Remarks
The cache stores a single replaceable snapshot of feature states. All reads return a
point-in-time copy so callers never observe a partially-updated dictionary. Updates are atomic
under a lightweight lock, making this safe for concurrent use by the background refresh
service and request-serving threads.
The cache is intentionally stateless beyond the current snapshot: it does not track history, publish change events, or enforce feature ID allow-lists. Those concerns belong in the orchestration layer.
Constructors
FeatureSnapshotCache(IReadOnlyDictionary<string,bool>, string, DateTimeOffset) Constructor
Initialises the cache with the bootstrap-seeded feature snapshot.
public FeatureSnapshotCache(System.Collections.Generic.IReadOnlyDictionary<string,bool> initialFeatures, string contractVersion, System.DateTimeOffset fetchedAt);
Parameters
initialFeatures System.Collections.Generic.IReadOnlyDictionary<System.String,System.Boolean>
Initial feature flag dictionary (may be empty, must not be null).
contractVersion System.String
The schema contract version associated with the snapshot.
fetchedAt System.DateTimeOffset
The UTC timestamp at which the snapshot was retrieved from the exp service.
Exceptions
System.ArgumentNullException
Thrown when initialFeatures is null.
Properties
FeatureSnapshotCache.ContractVersion Property
Gets the contract version of the currently cached snapshot.
public string ContractVersion { get; }
Property Value
FeatureSnapshotCache.CurrentFeatures Property
Gets a point-in-time copy of the current feature flag dictionary.
public System.Collections.Generic.IReadOnlyDictionary<string,bool> CurrentFeatures { get; }
Property Value
System.Collections.Generic.IReadOnlyDictionary<System.String,System.Boolean>
FeatureSnapshotCache.FetchedAt Property
Gets the UTC timestamp at which the current snapshot was fetched from the exp service.
public System.DateTimeOffset FetchedAt { get; }
Property Value
Methods
FeatureSnapshotCache.IsEnabled(string) Method
Returns true when the named feature is present and enabled in the current snapshot. Returns false for unknown feature identifiers (closed-world assumption).
public bool IsEnabled(string featureId);
Parameters
featureId System.String
The feature identifier to evaluate (must not be null or whitespace).
Returns
System.Boolean
true when the feature is explicitly enabled; false otherwise.
Exceptions
System.ArgumentException
Thrown when featureId is null or whitespace.
FeatureSnapshotCache.Update(IReadOnlyDictionary<string,bool>, string, DateTimeOffset) Method
Atomically replaces the current snapshot with the supplied values.
public void Update(System.Collections.Generic.IReadOnlyDictionary<string,bool> features, string contractVersion, System.DateTimeOffset fetchedAt);
Parameters
features System.Collections.Generic.IReadOnlyDictionary<System.String,System.Boolean>
Replacement feature flag dictionary (must not be null).
contractVersion System.String
The schema contract version of the new snapshot.
fetchedAt System.DateTimeOffset
The UTC timestamp at which the new snapshot was fetched.
Exceptions
System.ArgumentNullException
Thrown when features is null.
RateLimitPolicies Class
Defines the named rate limiting policy constants used across the API. These policy names are used to reference rate limiting policies when configuring endpoints.
public static class RateLimitPolicies
Inheritance System.Object 🡒 RateLimitPolicies
Remarks
Rate limiting policies control request throughput based on user identity and operation type. The actual policy configurations are registered in the Core project.
Policy Categories:
- StandardReads: High-throughput read operations (300 req/min)
- StandardWrites: Moderate write operations (60 req/min)
- AnalysisOperations: Resource-intensive AI/ML operations (10 req/hour)
- HealthCheck: Unlimited for monitoring systems
Fields
RateLimitPolicies.AnalysisOperations Field
Policy name for resource-intensive analysis operations (AI/ML processing). Allows 10 requests per hour per user/IP.
public const string AnalysisOperations = "AnalysisOperations";
Field Value
RateLimitPolicies.HealthCheck Field
Policy name for health check endpoints (unlimited for monitoring systems).
public const string HealthCheck = "HealthCheck";
Field Value
RateLimitPolicies.StandardReads Field
Policy name for standard read operations (GET requests). Allows 300 requests per minute per user/IP.
public const string StandardReads = "StandardReads";
Field Value
RateLimitPolicies.StandardWrites Field
Policy name for standard write operations (POST, PUT, PATCH, DELETE requests). Allows 60 requests per minute per user/IP.
public const string StandardWrites = "StandardWrites";
Field Value
Interfaces
IConfigProxyClient Interface
Single-key configuration fetcher that resolves individual config values from the exp service.
public interface IConfigProxyClient
Derived
↳ ConfigProxyClient
Methods
IConfigProxyClient.GetConfigValueAsync(string, string, CancellationToken) Method
Fetches a single indexed configuration value by name.
System.Threading.Tasks.Task<arolariu.Backend.Common.Configuration.ConfigValueResponse?> GetConfigValueAsync(string name, string? label=null, System.Threading.CancellationToken ct=default(System.Threading.CancellationToken));
Parameters
name System.String
The canonical configuration key name (for example: Endpoints:Service:Api).
label System.String
Optional Azure App Configuration label (for example: PRODUCTION). When provided the label is forwarded to the exp service.
ct System.Threading.CancellationToken
Cancellation token for the operation.
Returns
System.Threading.Tasks.Task<ConfigValueResponse>
The typed config value response, or null when the request fails or the service is unavailable.