-
Notifications
You must be signed in to change notification settings - Fork 0
how it works application configuration
There's one nuget package I found through research named ConfigurationSubstitutor by molinch
This allows for self-configured configuration and substitutions
Here's where it's added in the code
builder.Configuration.EnableSubstitutionsWithDelimitedFallbackDefaults("$(", ")", " ?? ");
In order for ConfigurationSubstitutor to configure app settings [using the syntax I provided], substitutions must start with "$(" and end with ")"
On top of that, a familiar delimited fallback default syntax is configured [familiar to C# developers at least] and resembles the null-coalescing operator
Here's a sample of its usage in the health checks ui
{
"Host": "localhost",
"Applications": {
"Mvc": "http://$(Host):5001",
"WebBff": "http://$(Host):5050",
"AddressService": "http://$(Host):5011",
"AddressWorker": "http://$(Host):5021",
"IdentityService": "http://$(Host):5005",
"OrderService": "http://$(Host):5012",
"OrderWorker": "http://$(Host):5022",
"TyresService": "http://$(Host):5013"
}
}
The Host
app setting is used to configure all the application endpoints
This is how the configured values would look like when retrieved from configuration
{
"Applications": {
"Mvc": "http://localhost:5001",
"WebBff": "http://localhost:5050",
"AddressService": "http://localhost:5011",
"AddressWorker": "http://localhost:5021",
"IdentityService": "http://localhost:5005",
"OrderService": "http://localhost:5012",
"OrderWorker": "http://localhost:5022",
"TyresService": "http://localhost:5013"
}
}
In docker-compose, the Host
app setting is overridden using an environment variable with its value set to host.docker.internal
App settings will then be configured like this
{
"Applications": {
"Mvc": "http://host.docker.internal:5001",
"WebBff": "http://host.docker.internal:5050",
"AddressService": "http://host.docker.internal:5011",
"AddressWorker": "http://host.docker.internal:5021",
"IdentityService": "http://host.docker.internal:5005",
"OrderService": "http://host.docker.internal:5012",
"OrderWorker": "http://host.docker.internal:5022",
"TyresService": "http://host.docker.internal:5013"
}
}
Here's an example of how the delimited default is used
{
"LoggingSinks": {
"Elasticsearch": {
"Enabled": "$(envUseElasticsearch ?? false)",
"Url": "$(envElasticsearchUrl ?? http://localhost:9201)"
}
}
}
Let's assume there's no environment variables available to override, this is what the result will be
{
"LoggingSinks": {
"Elasticsearch": {
"Enabled": false,
"Url": "http://localhost:9201"
}
}
}
In docker-compose, those environment variables are provided and therefore overrides the values in app settings
- envUseElasticsearch = true
- envElasticsearchUrl = http://elasticsearch:9200
The resulting configuration looks like this
{
"LoggingSinks": {
"Elasticsearch": {
"Enabled": true,
"Url": "http://elasticsearch:9200"
}
}
}
- Health Checks UI
- Mvc Frontend
- Web Backend-For-Frontend
- Address Service
- Address Worker
- Identity Service
- Order Service
- Order Worker
- Tyres Service