From ba0286692cbc08f8e2ff8ce65f9f7a7d557b0371 Mon Sep 17 00:00:00 2001 From: Riccardo Boero <ribo@nilu.no> Date: Mon, 16 Dec 2024 10:07:09 +0100 Subject: [PATCH] fix service call --- src/utils/db.jl | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/src/utils/db.jl b/src/utils/db.jl index 7212d83..18d913f 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"], -- GitLab