Real-world practical scenario dengan configuration yang umum digunakan: database connection, cache settings, dengan simple nested objects dan arrays of objects.
Standard application configuration untuk database connection pooling dan cache cluster configuration.
database:
host: localhost
port: 5432
name: middleware_db
username: ace_user
password: secure_pass_123
connectionPool:
minSize: 5
maxSize: 20
timeout: 30
allowedIPs:
- 192.168.1.100
- 192.168.1.101
- 10.0.0.50
cache:
enabled: true
ttl: 3600
provider: redis
nodes:
- host: redis1.example.com
port: 6379
- host: redis2.example.com
port: 6379
{
"database": {
"host": "localhost",
"port": "5432",
"name": "middleware_db",
"username": "ace_user",
"password": "secure_pass_123",
"connectionPool": {
"minSize": "5",
"maxSize": "20",
"timeout": "30"
},
"allowedIPs": ["192.168.1.100", "192.168.1.101", "10.0.0.50"]
},
"cache": {
"enabled": "true",
"ttl": "3600",
"provider": "redis",
"nodes": [
{
"host": "redis1.example.com",
"port": "6379"
},
{
"host": "redis2.example.com",
"port": "6379"
}
]
}
}
DECLARE dbConfig REFERENCE TO Environment.Variables;
DECLARE success BOOLEAN;
CALL ACE_LIB.getConfig(
'APP_DB_CONFIG',
'database',
'/path/to/CONFIG5.yaml',
'600',
dbConfig
) INTO success;
IF success THEN
-- Connection details
DECLARE dbHost CHARACTER dbConfig.host;
DECLARE dbPort CHARACTER dbConfig.port;
DECLARE dbName CHARACTER dbConfig.name;
-- Connection pool settings
DECLARE minPool CHARACTER dbConfig.connectionPool.minSize;
DECLARE maxPool CHARACTER dbConfig.connectionPool.maxSize;
-- Allowed IPs
DECLARE ipRef REFERENCE TO dbConfig.allowedIPs[1];
WHILE LASTMOVE(ipRef) DO
DECLARE allowedIP CHARACTER ipRef;
-- "192.168.1.100", "192.168.1.101", "10.0.0.50"
MOVE ipRef NEXTSIBLING;
END WHILE;
END IF;
DECLARE cacheConfig REFERENCE TO Environment.Variables;
DECLARE success BOOLEAN;
CALL ACE_LIB.getConfig(
'APP_CACHE_CONFIG',
'cache',
'/path/to/CONFIG5.yaml',
'600',
cacheConfig
) INTO success;
IF success THEN
-- Cache settings
DECLARE cacheEnabled CHARACTER cacheConfig.enabled;
DECLARE cacheTTL CHARACTER cacheConfig.ttl;
DECLARE cacheProvider CHARACTER cacheConfig.provider;
-- Redis nodes
DECLARE nodeRef REFERENCE TO cacheConfig.nodes[1];
WHILE LASTMOVE(nodeRef) DO
DECLARE nodeHost CHARACTER nodeRef.host;
DECLARE nodePort CHARACTER nodeRef.port;
-- Connect to redis node...
MOVE nodeRef NEXTSIBLING;
END WHILE;
END IF;
✅ Multiple root keys (database, cache)
✅ Simple nested objects (1-level deep)
✅ Arrays of simple strings (allowedIPs)
✅ Arrays of objects (nodes)
✅ Practical real-world config structure
✅ Multiple configs dari same file
"5432", "true")