Skip to content

Configuration

Service Framework uses a configuration object to control the runtime. You can build it programmatically or load from a JSON file.

The Configuration Object

The framework::configuration class holds settings for ports, TLS, JWT, logging, gossip, quotas, and more.

Minimal Configuration

cpp
#include <framework.hpp>

using namespace framework;

int main() {
    configuration config;
    config.ports_.node_port_.store(10000);
    config.ports_.client_port_.store(8080);

    framework::app app(config);
    app.run_http_service(8080);
    app.run();
    return 0;
}

Loading from a JSON File

cpp
configuration config;
config.load_from_json("config.json");

framework::app app(config);

After loading from JSON, you can synchronize the scopes array to the bitset:

cpp
config.sync_log_bitset();  // syncs logging_.scopes_ → logging_.scope_bitset_

JSON Config Reference

The JSON configuration structure maps to the configuration class fields. Strings use std::shared_ptr<const std::string> internally:

cpp
config.seed_.host_.store(std::make_shared<const std::string>("10.0.0.1"));

Ports & Seed

JSON keyC++ fieldTypeDefaultDescription
ports.nodeports_.node_port_integer10000Inter-node mesh port
ports.clientports_.client_port_integer0Default client listener port. Overridden by the port argument passed to run_http_service(port). With default 0, no listener starts automatically — you must call run_http_service() explicitly.
seed.enabledseed_.enabled_booleanfalseEnable seed-based discovery
seed.hostseed_.host_string"127.0.0.1"Seed node hostname
seed.node_portseed_.node_port_integer0Seed node mesh port
seed.client_portseed_.client_port_integer0Seed client port
seed.retry_interval_msseed_.retry_interval_ms_integer2000Seed reconnect interval

Node

JSON keyC++ fieldTypeDefaultDescription
node.hostnode_.host_string"127.0.0.1"Advertised hostname
node.max_connectionsnode_.max_connections_integer5Max connections per peer
node.max_peersnode_.max_peers_integer8Max total peers
node.load_balance_strategynode_.load_balance_strategy_string"roundrobin""random", "roundrobin", "least_loaded"
node.max_send_receiversnode_.max_send_receivers_integer100Max recipients per send
node.metrics_interval_msnode_.metrics_interval_ms_integer60000Metrics report interval
node.app_keynode_.app_key_string"default_app_key"Application identifier
node.max_frame_sizenode_.max_frame_size_integer65536Max frame size (bytes)
node.max_payload_sizenode_.max_payload_size_integer10MBMax payload size (bytes)
node.max_hopsnode_.max_hops_integer10Max message propagation hops
node.max_queue_sizenode_.max_queue_size_integer5000Outbound message queue
node.read_timeout_secondsnode_.read_timeout_seconds_integer10Read timeout

Gossip

JSON keyC++ fieldTypeDefaultDescription
gossip.hybrid_thresholdgossip_.hybrid_threshold_integer10Max peers for direct ping
gossip.rumor_limit_per_framegossip_.rumor_limit_per_frame_integer5Max rumors per gossip cycle
gossip.cycle_interval_msgossip_.cycle_interval_ms_integer1000Gossip cycle interval
gossip.suspect_timeout_sgossip_.suspect_timeout_s_integer10Time before marking suspect
gossip.dead_timeout_sgossip_.dead_timeout_s_integer30Time before marking dead
gossip.prune_timeout_sgossip_.prune_timeout_s_integer300Time before removing dead nodes

TLS

JSON keyC++ fieldTypeDefaultDescription
tls.cert_chain_filetls_.cert_chain_file_stringPEM certificate chain
tls.private_key_filetls_.private_key_file_stringPEM private key
tls.ca_filetls_.ca_file_stringCA bundle for peer verification

JWT

JSON keyC++ fieldTypeDefaultDescription
jwt.keys.signaturejwt_.keys_.signature_string(default)Base64 JWT signing key
jwt.keys.encryptionjwt_.keys_.encryption_string(default)Base64 JWT encryption key

CORS

JSON keyC++ fieldTypeDefaultDescription
cors.enabledcors_.enabled_booleantrueEnable CORS headers
cors.origincors_.origin_string"*"Allowed origin
cors.headerscors_.headers_string"Content-Type, Authorization"Allowed headers

Logging

JSON keyC++ fieldTypeDefaultDescription
logging.scopeslogging_.scopes_array["service","operational","verbose"]Enabled log scopes

Latency

JSON keyC++ fieldTypeDefaultDescription
latency.enabledlatency_.enabled_booleantrueEnable latency tracking
latency.interval_slatency_.interval_s_integer5Measurement interval
latency.timeout_slatency_.timeout_s_integer60Latency timeout
latency.history_sizelatency_.history_size_integer10Readings to keep

WebSocket

JSON keyC++ fieldTypeDefaultDescription
websocket.max_queue_sizewebsocket_.max_queue_size_integer1000Send queue per connection
websocket.max_subscriptions_per_sessionwebsocket_.max_subscriptions_per_session_integer1000Subscriptions per session
websocket.max_total_channelswebsocket_.max_total_channels_integer10000Total channels limit

HTTP

JSON keyC++ fieldTypeDefaultDescription
http.pipeline_queue_limithttp_.pipeline_queue_limit_integer8HTTP pipelined requests

Validation

JSON keyC++ fieldTypeDefaultDescription
validation.regex_timeout_msvalidation_.regex_timeout_ms_integer100Regex match timeout

WAL

JSON keyC++ fieldTypeDefaultDescription
wal.enabledwal_.enabled_booleantrueEnable write-ahead log
wal.pathwal_.path_string"storage/wal.log"WAL file path

Quotas

JSON keyC++ fieldTypeDefaultDescription
quotas.enabledquotas_.enabled_booleanfalseEnable rate limiting
quotas.ingress_bytes_limitquotas_.ingress_bytes_limit_integer-1Max inbound bytes per window
quotas.egress_bytes_limitquotas_.egress_bytes_limit_integer-1Max outbound bytes per window
quotas.msg_count_limitquotas_.msg_count_limit_integer-1Max messages per window
quotas.window_secondsquotas_.window_seconds_integer3600Sliding window duration
quotas.permissivequotas_.permissive_booleanfalseLog only, no action
quotas.default_rulesquotas_.default_rules_array[]Default quota limit rules
quotas.allowlistquotas_.allowlist_array[]Opcodes exempt from quotas
quotas.blocklistquotas_.blocklist_array[]Opcodes always blocked
quotas.bypass_grantsquotas_.bypass_grants_array["system:admin"]JWT grants that bypass quotas

Quorum

JSON keyC++ fieldTypeDefaultDescription
quorum.enabledquorum_.enabled_booleanfalseEnable quorum checks

Threads

JSON keyC++ fieldTypeDefaultDescription
threadsthreads_integer4I/O thread pool size