results_backend
This module provides functionality for managing and configuring connection strings
and SSL settings for various results backends, including MySQL, Redis, Rediss, and SQLite.
The module relies on the application's configuration file (app.yaml) to determine backend
settings and certificate paths.
get_connection_string(include_password=True)
Determines the appropriate results backend to use based on the package configuration and returns the corresponding connection string.
If a URL is explicitly defined in the configuration (CONFIG.results_backend.url),
it is returned as the connection string.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
include_password
|
bool
|
Whether to include the password in the connection string. If True, the password will be included; otherwise, it will be masked. |
True
|
Returns:
| Type | Description |
|---|---|
str
|
The connection string for the configured results backend. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the specified results backend in the configuration is not supported. |
Source code in merlin/config/results_backend.py
get_mysql(certs_path=None, mysql_certs=None, include_password=True)
Constructs and returns a formatted MySQL connection string based on the provided parameters and application configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
certs_path
|
str
|
The path to the directory containing SSL certificates and password files. |
None
|
mysql_certs
|
dict
|
A dictionary mapping MySQL certificate keys (e.g., 'ssl_key', 'ssl_cert', 'ssl_ca')
to their expected filenames. If this is None, it uses the default |
None
|
include_password
|
bool
|
Whether to include the password in the connection string. If True, the password will be included; otherwise, it will be masked. |
True
|
Returns:
| Type | Description |
|---|---|
str
|
A formatted MySQL connection string. |
Raises:
| Type | Description |
|---|---|
TypeError
|
|
Source code in merlin/config/results_backend.py
get_mysql_config(certs_path, mysql_certs)
Determines whether all required information for connecting to MySQL as the Celery results backend is available, and returns the MySQL SSL configuration or certificate paths.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
certs_path
|
str
|
The path to the directory containing SSL certificates and password files. |
required |
mysql_certs
|
Dict
|
A dictionary mapping certificate keys (e.g., 'cert', 'key', 'ca') to their expected filenames. |
required |
Returns:
| Type | Description |
|---|---|
Dict
|
A dictionary containing the paths to the required MySQL certificates if they exist. |
Source code in merlin/config/results_backend.py
get_redis(certs_path=None, include_password=True, ssl=False)
Constructs and returns a Redis or Rediss connection URL based on the provided parameters and configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
certs_path
|
str
|
The path to SSL certificates and password files. |
None
|
include_password
|
bool
|
Whether to include the password in the connection URL. If True, the password will be included; otherwise, it will be masked. |
True
|
ssl
|
bool
|
Flag indicating whether to use SSL for the connection (Rediss). If True, the connection URL will use the "rediss" protocol; otherwise, it will use "redis". |
False
|
Returns:
| Type | Description |
|---|---|
str
|
A Redis or Rediss connection URL formatted based on the provided parameters and configuration. |
Source code in merlin/config/results_backend.py
get_ssl_config(celery_check=False)
Retrieves the SSL configuration for the results backend based on the settings
specified in the app.yaml configuration file.
This function determines whether SSL should be enabled for the results backend and returns the appropriate configuration. It supports various backend types such as MySQL, Redis, and Rediss.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
celery_check
|
bool
|
If True, the function returns the SSL settings specifically for configuring Celery. |
False
|
Returns:
| Type | Description |
|---|---|
bool
|
The SSL configuration for the results backend. Returns |