title: "Feature Configuration Reference" description: "Detailed reference for configuring the Server Customization System in Navius applications" category: reference tags:
- reference
- configuration
- features
- server-customization
- settings related:
- ../../guides/features/server-customization-cli.md
- ../../examples/server-customization-example.md
- ../../feature-system.md last_updated: March 27, 2025 version: 1.0
Feature Configuration Reference
This document provides detailed information about configuring the Server Customization System in Navius.
Overview
The Server Customization System allows you to selectively enable or disable features based on your specific requirements, optimizing performance, reducing attack surface, and customizing the server to your exact needs.
Configuration Structure
Feature configuration can be defined in your application configuration files:
features:
# Global feature configuration
discovery_enabled: true
# Explicitly enabled features
enabled_features:
- core
- security
- metrics
- caching
- auth:oauth
# Explicitly disabled features
disabled_features:
- advanced_metrics
- tracing
# Feature-specific configuration
feature_config:
caching:
redis_enabled: true
memory_cache_size: 10000
metrics:
collect_interval_seconds: 15
enable_prometheus: true
auth:
providers:
- type: oauth
enabled: true
- type: saml
enabled: false
Configuration Options
Global Feature Options
Option | Type | Default | Description |
---|---|---|---|
discovery_enabled | boolean | true | Enables automatic discovery of features |
enabled_features | array | [] | List of features to explicitly enable |
disabled_features | array | [] | List of features to explicitly disable |
feature_config | object | {} | Feature-specific configuration options |
Feature Configuration
Each feature can have its own configuration section. Here are the common pattern options:
feature_config:
feature_name:
enabled: true # Can override the global enabled setting
# Feature-specific options follow
Feature Reference
Core Features
Core features are always enabled and cannot be disabled.
Feature ID | Description |
---|---|
core | Core server functionality, required for operation |
config | Configuration system, required for operation |
error_handling | Error handling framework, required for operation |
Optional Features
These features can be enabled or disabled based on your needs.
Feature ID | Description | Dependencies |
---|---|---|
metrics | Metrics collection and reporting | none |
advanced_metrics | Enhanced metrics for detailed monitoring | metrics |
tracing | Distributed tracing support | none |
logging | Logging system | none |
structured_logging | Structured logging with JSON output | logging |
caching | Basic caching functionality | none |
redis_caching | Redis cache provider | caching |
two_tier_caching | Two-tier cache system | caching |
auth | Authentication system | none |
auth:oauth | OAuth2 authentication provider | auth |
auth:saml | SAML authentication provider | auth |
auth:jwt | JWT authentication and validation | auth |
security | Security features | none |
rate_limiting | Rate limiting for API endpoints | security |
api | API framework | none |
graphql | GraphQL support | api |
rest | REST API support | api |
db | Database abstraction | none |
db:postgres | PostgreSQL support | db |
db:mysql | MySQL support | db |
reliability | Reliability patterns | none |
circuit_breaker | Circuit breaker pattern | reliability |
retry | Automatic retry with backoff | reliability |
timeout | Request timeout handling | reliability |
fallback | Fallback mechanisms | reliability |
bulkhead | Isolation patterns | reliability |
cli | Command-line interface | none |
scheduler | Task scheduling | none |
websocket | WebSocket support | none |
sse | Server-sent events support | none |
Environment Variables
You can also configure features using environment variables:
Environment Variable | Description |
---|---|
NAVIUS_FEATURES_DISCOVERY_ENABLED | Enable/disable feature discovery (true /false ) |
NAVIUS_FEATURES_ENABLED | Comma-separated list of features to enable |
NAVIUS_FEATURES_DISABLED | Comma-separated list of features to disable |
NAVIUS_FEATURE_METRICS_ENABLED | Enable/disable specific feature (e.g., metrics) |
NAVIUS_FEATURE_CACHING_REDIS_ENABLED | Enable/disable feature-specific option |
Feature File
You can also specify features using a YAML or JSON file:
# features.yaml
enabled:
- core
- security
- caching
- metrics
disabled:
- tracing
- advanced_metrics
configuration:
caching:
redis_enabled: true
Load this configuration using:
./navius --features=features.yaml
Or specify the environment variable:
NAVIUS_FEATURES_FILE=features.yaml ./navius
Feature Detection in Code
You can check for feature availability at runtime:
#![allow(unused)] fn main() { use navius::core::features::RuntimeFeatures; fn initialize_metrics(features: &RuntimeFeatures) { if !features.is_enabled("metrics") { return; } // Initialize metrics println!("Initializing metrics..."); // Check for advanced metrics if features.is_enabled("advanced_metrics") { println!("Initializing advanced metrics..."); } } }
Feature Dependency Resolution
When a feature is enabled, its dependencies are automatically enabled as well. For example, enabling advanced_metrics
will automatically enable metrics
.
features:
enabled_features:
- advanced_metrics # This will automatically enable 'metrics' as well
Likewise, when a feature is disabled, any features that depend on it will also be disabled.
Feature Configuration API
The Server Customization System provides a programmatic API for configuring features:
#![allow(unused)] fn main() { use navius::core::features::{FeatureRegistry, FeatureConfig}; fn configure_features() -> FeatureRegistry { let mut registry = FeatureRegistry::new(); // Enable specific features registry.enable("caching").unwrap(); registry.enable("security").unwrap(); // Disable specific features registry.disable("tracing").unwrap(); // Configure a specific feature let mut caching_config = FeatureConfig::new("caching"); caching_config.set_option("redis_enabled", true); caching_config.set_option("memory_cache_size", 10000); registry.configure(caching_config).unwrap(); // Resolve dependencies registry.resolve_dependencies().unwrap(); registry } }
Best Practices
- Start Minimal: Begin with only the essential features enabled, then add more as needed
- Group Related Features: Use feature groups to enable/disable related functionality
- Test Combinations: Test various feature combinations to ensure they work together
- Document Enabled Features: Keep track of which features are enabled in your deployment
- Monitor Impact: Watch for performance changes when enabling/disabling features
- Use Environment-Specific Configurations: Create different feature configurations for development, testing, and production
Feature Optimization Techniques
The Server Customization System uses several techniques to optimize the application based on enabled features:
- Compile-Time Exclusion: Features can be excluded at compile time using Cargo features
- Conditional Code: Code blocks can be conditionally executed based on feature availability
- Dynamic Loading: Some features can be dynamically loaded only when needed
- Dependency Tree Pruning: Dependencies are only included if required by enabled features
Example Configurations
Minimal Server (API Only)
features:
enabled_features:
- core
- api
- rest
- security
disabled_features:
- metrics
- tracing
- caching
- graphql
- websocket
- scheduler
Full Monitoring Server
features:
enabled_features:
- core
- metrics
- advanced_metrics
- tracing
- structured_logging
- security
disabled_features:
- api
- db
Production API Server
features:
enabled_features:
- core
- api
- rest
- security
- metrics
- caching
- redis_caching
- two_tier_caching
- reliability
- circuit_breaker
- retry
- timeout
- rate_limiting
disabled_features:
- advanced_metrics
- tracing
- websocket
- sse