Service configuration struct that defines how to connect to a remote service and pull its function configurations.
Version Checking
When version_module and version_function are configured, the ConfigPuller
will first call the lightweight version check RPC before performing a full
config pull. If the returned version matches the locally stored version for
that service, the full pull is skipped — saving network bandwidth and
reducing load on remote nodes.
The remote service should implement a version function that returns a value that changes whenever the function configurations change. Good candidates include:
- A monotonically increasing integer (e.g.,
1,2,3) - A semantic version string (e.g.,
"1.2.3") - A content hash of the config data (e.g.,
"a1b2c3d4") - A timestamp of the last config change (e.g.,
"2024-01-15T10:30:00Z")
The version value is compared using strict equality (==), so any format
that can be compared this way will work.
Example Configuration
%ServiceConfig{
service: "user_service",
nodes: ["node1@host", "node2@host"],
module: UserService.Api,
function: :get_config,
args: [],
version_module: UserService.Api,
version_function: :get_config_version,
version_args: []
}If version_module or version_function is nil, version checking is
disabled and the full config pull will always be performed (backward
compatible behavior).
Summary
Functions
Creates a ServiceConfig struct from a map (typically from application config).
Returns true if version checking is configured for this service.
Types
Functions
Creates a ServiceConfig struct from a map (typically from application config).
Handles both atom and string keys, and converts string module/function names to atoms when necessary.
Returns true if version checking is configured for this service.
A service is considered to have version checking enabled when both
version_module and version_function are non-nil.