diff --git a/src/utils/db.jl b/src/utils/db.jl index 7212d8337f11cc4f82f0d17a1b7af614501ad2e8..18d913f15384526668d5e3a8731dc6addceb02d1 100644 --- a/src/utils/db.jl +++ b/src/utils/db.jl @@ -125,8 +125,42 @@ function get_results_connection(service::OrchestratorRegistry.Service) return conn end +""" +get_results_connection(service_dict::Dict) -> Connection + +Establishes a database connection using the provided service configuration. + +This function creates a `Service` object from the given `service_dict` and uses it to establish a database connection. The connection is configured based on the `host` and `port` specified in the dictionary. + +# Arguments +- `service_dict::Dict`: A dictionary containing the following keys: + - `"host"`: The hostname or IP address of the database service. + - `"port"`: The port number for the database service. + +# Returns +- `Connection`: A connection object to the database service. + +# Behavior +- Constructs a `Service` object using the provided host and port from `service_dict`. +- Calls `get_connection` with the constructed `Service` object to establish the database connection. + +# Example +Define the service dictionary and establish a connection: + +```julia +service_dict = Dict( + "host" => "127.0.0.1", + "port" => 3306 +) + +connection = get_results_connection(service_dict) +println(connection) +``` + +In this example, a database connection is established using the host `127.0.0.1` and port `3306`. +""" function get_results_connection(service_dict::Dict) - service = Service( + service = OrchestratorRegistry.Service( "id", "name", service_dict["host"],