rib/interpreter/
rib_function_invoke.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 crate::{ComponentDependencyKey, InstructionId};
16use async_trait::async_trait;
17use golem_wasm_ast::analysis::AnalysedType;
18use golem_wasm_rpc::ValueAndType;
19
20#[async_trait]
21pub trait RibComponentFunctionInvoke {
22    async fn invoke(
23        &self,
24        component_dependency_key: ComponentDependencyKey,
25        instruction_id: &InstructionId,
26        worker_name: EvaluatedWorkerName,
27        function_name: EvaluatedFqFn,
28        args: EvaluatedFnArgs,
29        return_type: Option<AnalysedType>,
30    ) -> RibFunctionInvokeResult;
31}
32
33pub type RibFunctionInvokeResult =
34    Result<Option<ValueAndType>, Box<dyn std::error::Error + Send + Sync>>;
35
36#[derive(Debug)]
37pub struct EvaluatedFqFn(pub String);
38
39#[derive(Clone)]
40pub struct EvaluatedWorkerName(pub String);
41
42pub struct EvaluatedFnArgs(pub Vec<ValueAndType>);