Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Settings

The settings of a yuno, defining the tree of gobj’s to be created and their configuration, can be done with the function:

    PUBLIC json_t *json_config(
        BOOL print_verbose_config,
        BOOL print_final_config,
        const char *fixed_config,
        const char *variable_config,
        const char *config_json_file,
        const char *parameter_config,
        pe_flag_t quit
    );

Source code in:

The json_config() function is a utility in Yuneta designed to generate a final JSON configuration by merging multiple JSON inputs. It supports advanced features like comment handling, variable substitution, and range-based expansion. The function can output the resulting configuration, validate it, and handle errors robustly.

The json_config() function merges multiple JSON configurations into a single final configuration string, following a specific order of precedence. It also includes features like comment handling, variable substitution, and range-based expansion for flexibility and advanced use cases.

The return of json_config() is a json_t * object (owned by the caller, must be freed with json_decref()).

Global Settings

If the final JSON has a key global, his value will be used as the argument jn_global_settings in gobj_start_up, and will be merge to kw when creating a gobj.

Features

1. Global Variable Substitution

The function replaces strings enclosed in (^^ ^^) with corresponding values from the __json_config_variables__ dictionary. This dictionary includes global variables returned by gobj_global_variables().

Predefined Variables in __json_config_variables__

VariableDescription
__node_owner__Node owner of the Yuno.
__realm_id__Realm ID of the Yuno.
__realm_owner__Realm owner of the Yuno.
__realm_role__Realm role of the Yuno.
__realm_name__Name of the realm.
__realm_env__Environment of the realm.
__yuno_id__Unique ID of the Yuno.
__yuno_role__Role of the Yuno.
__yuno_name__Name of the Yuno.
__yuno_tag__Tag of the Yuno.
__yuno_role_plus_name__Role and name of the Yuno.
__hostname__Hostname of the system.
__sys_system_name__System name (Linux only).
__sys_node_name__Node name (Linux only).
__sys_version__System version (Linux only).
__sys_release__System release (Linux only).
__sys_machine__Machine type (Linux only).
__tls_library__Active TLS backend: "openssl" or "mbedtls" (compile-time).
__bind_ip__Bind IP address of the Yuno.
__multiple__Whether the Yuno allows multiple instances (boolean).

2. Comment Handling

Supports single-line comments using the syntax ##^ in JSON strings.

3. Range-Based Expansion

Expands JSON objects based on ranges defined within the input JSON. For example:

{
"__range__": [12000, 12002],
"__content__": {
"item(^^__range__^^)": { "id": "(^^__range__^^)" }
}
}

Will expand into:

{
"item12000": { "id": "12000" },
"item12001": { "id": "12001" },
"item12002": { "id": "12002" }
}

4. Order of Precedence

The function processes inputs in the following order:

  1. fixed_config: Non-writable configuration.

  2. variable_config: Writable configuration.

  3. config_json_file: Overwrites variable_config if specified.

  4. parameter_config: Final overwrites.


Behavior


Return Value