Represents the data a remote node pushes to the PhoenixGenApi server node.
This struct is used when a remote node actively pushes its service configuration to the server, as opposed to the server pulling it. It contains all the necessary information to register the service, including function configurations and optional pull-based registration details.
Version Checking
The config_version field represents the version of the entire service
configuration. When the server receives a push, it compares this version
with the locally stored version. If they match, the push can be skipped
since the server already has the current configuration.
Auto-Pull Registration
When module and function are provided, the to_service_config/1 function
can convert this PushConfig into a ServiceConfig for automatic pull-based
registration. This allows the server to periodically refresh the configuration
from the remote node after the initial push.
Validation
Use valid?/1 for a quick boolean check or validate_with_details/1 for
detailed error messages when validation fails.
Example
%PushConfig{
service: "user_service",
nodes: [:"node1@host", :"node2@host"],
config_version: "1.2.3",
fun_configs: [%FunConfig{...}],
module: UserService.Api,
function: :get_config,
args: [],
version_module: UserService.Api,
version_function: :get_config_version,
version_args: []
}
Summary
Functions
Creates a PushConfig struct from a map using Nestru for decoding.
Converts the PushConfig to a ServiceConfig for auto-pull registration.
Validates the push configuration.
Validates the push configuration and returns detailed error information.
Types
@type t() :: %PhoenixGenApi.Structs.PushConfig{ args: list(), config_version: String.t(), fun_configs: [PhoenixGenApi.Structs.FunConfig.t()], function: atom() | nil, module: module() | nil, nodes: [atom() | String.t()], service: atom() | String.t(), version_args: list(), version_function: atom() | nil, version_module: module() | nil }
Push configuration struct for remote node pushes.
Functions
Creates a PushConfig struct from a map using Nestru for decoding.
@spec to_service_config(t()) :: PhoenixGenApi.Structs.ServiceConfig.t() | nil
Converts the PushConfig to a ServiceConfig for auto-pull registration.
Only creates a ServiceConfig if both module and function are provided.
Returns nil if either is missing.
The resulting ServiceConfig can be used by the ConfigPuller to periodically
refresh the configuration from the remote node.
Validates the push configuration.
Returns true if all configuration fields are valid, false otherwise.
Logs detailed error messages for each invalid field.
Validation Checks
servicemust not be nilnodesmust be a non-empty list of atoms or stringsconfig_versionmust be a non-empty stringfun_configsmust be a non-empty list ofFunConfigstructs- All
fun_configsmust have the same service name as the push config - All
fun_configsmust have valid versions
Validates the push configuration and returns detailed error information.
Returns {:ok, config} if valid, or {:error, [error_messages]} if invalid.