configfacets/core-concepts
Examples of application configurations aligned with Configfacet's core concepts.
Authentication
Add API authentication details
Readme
User instructions for this resource
Configfacets Example: Environment-Based Configuration
Below is a Configfacets example demonstrating a configuration type that adapts based on the deployment environment of the API Service. This service requires RabbitMQ, Redis, Elasticsearch, and S3 bucket details, which vary by environment. Additionally, feature flags control how configuration details are retrieved.
Requirements
Environment | Description |
---|---|
Development | Developers run the codebase locally. Backend developers must configure RabbitMQ while disabling other integrations like Elasticsearch using feature flags. |
Staging | Deployed in an internal cluster managed by the company's operations team, including Elasticsearch, RabbitMQ, and Redis. |
Production (AWS East & West) | The application runs across AWS East and West Coast data centers. API services in both regions share a common Redis instance but maintain separate S3 buckets and Elasticsearch instances. |
Design Considerations
{
"name": "API Service",
"facets": [
"master"
],
"features": {
"is_s3_enabled": false,
"is_redis_enabled": false,
"is_rabbitmq_enabled": false,
"is_elasticsearch_enabled": false
},
"rabbitmq": {
"port": "{{ rabbitmq_port }}"
}
}
- All integrations (RabbitMQ, Redis, etc.) are disabled by default.
- Common values across environments are stored in
, ensuring they are included regardless of the facet filters clients use.facet:master
{
"facets": [
"env:dev"
],
"features": {
"is_rabbitmq_enabled": true
},
"rabbitmq": {
"host": "127.0.0.1"
}
}
- RabbitMQ is expected to run locally, so integration is enabled with specific configuration details.
{
"facets": [
"env:nonprod",
"cluster:internal"
],
"features": {
"is_rabbitmq_enabled": true
},
"rabbitmq": {
"host": "10.0.0.32"
}
}
- Used by the CI/CD pipeline and deployed with a shared RabbitMQ instance.
{
"facets": [
"env:prod"
],
"features": {
"is_s3_enabled": true,
"is_redis_enabled": true,
"is_rabbitmq_enabled": true,
"is_elasticsearch_enabled": true
}
},
{
"s3": {
"bucket": "my_app_bucket"
},
"redis": {
"host": "mycachecluster.abcdef.ng.0001.use1.cache.amazonaws.com",
"port": "{{ redis_port }}"
},
"facets": [
"env:prod",
"cluster:aws"
]
}
- Uses a shared Redis instance and a common S3 bucket name across data centers.
- All features are enabled by default.
- Configuration is split into two sections for better clarity and for merging logic see Core Concepts.
{
"s3": {
"host": "https://s3.us-east-1.amazonaws.com"
},
"facets": [
"env:prod",
"cluster:aws",
"region:east"
],
"rabbitmq": {
"host": "rabbitmq.cabcdefghijk.us-east-1.rds.amazonaws.com"
},
"elasticsearch": {
"host": "https://search-myapp-abcdefg12345.us-east-1.es.amazonaws.com"
}
},
{
"s3": {
"host": "https://s3.us-west-1.amazonaws.com"
},
"facets": [
"env:prod",
"cluster:aws",
"region:west"
],
"rabbitmq": {
"host": "rabbitmq.cabcdefghijk.us-west-1.rds.amazonaws.com"
},
"elasticsearch": {
"host": "https://search-myapp-abcdefg12345.us-west-1.es.amazonaws.com"
}
}
- Each region has its own RabbitMQ, Elasticsearch, and S3 bucket instances.
This structure ensures that configurations are modular, environment-specific, and efficiently managed using facet-based filtering.
Interactive Examples
Explore above links and use
to check interactive examples.Try out
Usages
You can use any HTTP client in your preferred programming language to interact with Configfacets.
Currently, Configfacets provides a Python & NPM client, but we're open to supporting additional languages. If you're interested, feel free to reach out to us on our Discord channel.
pip install configfacets
Example Usage in Python
from configfacets.configuration import Configuration
config = Configuration(
source="https://configfacets.com/apis/repos/configfacets/core-concepts/appconfigs/resources/collections/api-configurations/exec?format=json",
sourceType="url",
apiKey="<your_api_key>",
postBody={"facets":["env:prod","cluster:aws","region:east"]},
)
config.fetch()
resp = config.get_resp()
isS3Enabled = config.get_value("features.is_s3_enabled")
print("Is S3 enabled:{}".format(isS3Enabled))
npm install configfacets
Example Usage in NPM
import Configfacets from "configfacets";
(async () => {
const config = new Configfacets(
"https://configfacets.com/apis/repos/configfacets/core-concepts/appconfigs/resources/collections/api-configurations/exec?format=json",
"url",
"<your_api_key>",
{ facets: ["env:prod","cluster:aws","region:east"] }
);
await config.fetch();
console.log(
"Is S3 enabled:",
config.getValue("features.is_s3_enabled")
);
})();
Refer to the Go client repository for setup and example usage.
For a raw
request, check the cURL tab below.cURL