golem_rib_repl/dependency_manager.rs
1// Copyright 2024-2025 Golem Cloud
2//
3// Licensed under the Golem Source License v1.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://license.golem.cloud/LICENSE
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15use async_trait::async_trait;
16use rib::ComponentDependency;
17use std::path::Path;
18
19/// Dependency manager for the Rib REPL environment.
20#[async_trait]
21pub trait RibDependencyManager {
22 /// Deploys all components within the current context if they are not already registered
23 /// with the Golem engine. Returns a list of successfully registered components.
24 ///
25 /// Note: It is the responsibility of the REPL client to resolve component paths.
26 /// In the future, Rib may support multiple components.
27 async fn get_dependencies(&self) -> anyhow::Result<ReplComponentDependencies>;
28
29 /// Deploys a specific component if the REPL was started with a reference to it.
30 ///
31 /// Currently, dynamic component loading is not supported.
32 ///
33 /// # Arguments
34 ///
35 /// * `source_path` - The file path to the component.
36 /// * `component_name` - The name of the component.
37 ///
38 /// # Returns
39 ///
40 /// Returns a `ComponentDependency` on success or an error message as a `String` if the operation fails.
41 async fn add_component(
42 &self,
43 source_path: &Path,
44 component_name: String,
45 ) -> anyhow::Result<ComponentDependency>;
46}
47
48pub struct ReplComponentDependencies {
49 pub component_dependencies: Vec<ComponentDependency>,
50}