diff --git a/golem-rib/src/call_type.rs b/golem-rib/src/call_type.rs index f0ef76e7d4..7bae88a88a 100644 --- a/golem-rib/src/call_type.rs +++ b/golem-rib/src/call_type.rs @@ -12,14 +12,14 @@ // See the License for the specific language governing permissions and // limitations under the License. -use crate::ParsedFunctionName; +use crate::{DynamicParsedFunctionName, ParsedFunctionName}; use bincode::{Decode, Encode}; use std::convert::TryFrom; use std::fmt::Display; #[derive(Debug, PartialEq, Eq, Clone, Encode, Decode)] pub enum CallType { - Function(ParsedFunctionName), + Function(DynamicParsedFunctionName), VariantConstructor(String), EnumConstructor(String), } diff --git a/golem-rib/src/compiler/byte_code.rs b/golem-rib/src/compiler/byte_code.rs index 8b970b9872..7e7112dac1 100644 --- a/golem-rib/src/compiler/byte_code.rs +++ b/golem-rib/src/compiler/byte_code.rs @@ -84,7 +84,10 @@ impl From for ProtoRibByteCode { mod internal { use crate::compiler::desugar::desugar_pattern_match; - use crate::{AnalysedTypeWithUnit, Expr, InferredType, InstructionId, RibIR}; + use crate::{ + AnalysedTypeWithUnit, DynamicParsedFunctionReference, Expr, FunctionReferenceType, + InferredType, InstructionId, ParsedFunctionName, ParsedFunctionReference, RibIR, + }; use golem_wasm_ast::analysis::AnalysedType; use golem_wasm_rpc::protobuf::type_annotated_value::TypeAnnotatedValue; @@ -235,43 +238,144 @@ mod internal { )?)); } - Expr::Call(invocation_name, arguments, inferred_type) => { - for expr in arguments.iter().rev() { - stack.push(ExprState::from_expr(expr)); - } - - match invocation_name { - CallType::Function(parsed_function_name) => { - let function_result_type = if inferred_type.is_unit() { - AnalysedTypeWithUnit::Unit - } else { - AnalysedTypeWithUnit::Type(convert_to_analysed_type_for( - expr, - inferred_type, - )?) - }; - - instructions.push(RibIR::InvokeFunction( - parsed_function_name.clone(), - arguments.len(), - function_result_type, - )); + Expr::Call(invocation_name, arguments, inferred_type) => match invocation_name { + CallType::Function(parsed_function_name) => { + let function_result_type = if inferred_type.is_unit() { + AnalysedTypeWithUnit::Unit + } else { + AnalysedTypeWithUnit::Type(convert_to_analysed_type_for( + expr, + inferred_type, + )?) + }; + + let site = parsed_function_name.site.clone(); + + match &parsed_function_name.function { + DynamicParsedFunctionReference::Function { function } => { + instructions.push(RibIR::CreateFunctionName( + site, + FunctionReferenceType::Function(function.clone()), + )) + } + + DynamicParsedFunctionReference::RawResourceConstructor { resource } => { + instructions.push(RibIR::CreateFunctionName( + site, + FunctionReferenceType::RawResourceConstructor(resource.clone()), + )) + } + DynamicParsedFunctionReference::RawResourceDrop { resource } => { + instructions.push(RibIR::CreateFunctionName( + site, + FunctionReferenceType::RawResourceDrop(resource.clone()), + )) + } + DynamicParsedFunctionReference::RawResourceMethod { resource, method } => { + instructions.push(RibIR::CreateFunctionName( + site, + FunctionReferenceType::RawResourceMethod( + resource.clone(), + method.clone(), + ), + )) + } + DynamicParsedFunctionReference::RawResourceStaticMethod { + resource, + method, + } => instructions.push(RibIR::CreateFunctionName( + site, + FunctionReferenceType::RawResourceStaticMethod( + resource.clone(), + method.clone(), + ), + )), + DynamicParsedFunctionReference::IndexedResourceConstructor { + resource, + resource_params, + } => { + for param in resource_params { + stack.push(ExprState::from_expr(¶m.0)); + } + instructions.push(RibIR::CreateFunctionName( + site, + FunctionReferenceType::IndexedResourceConstructor( + resource.clone(), + resource_params.len(), + ), + )) + } + DynamicParsedFunctionReference::IndexedResourceMethod { + resource, + resource_params, + method, + } => { + for param in resource_params { + stack.push(ExprState::from_expr(¶m.0)); + } + instructions.push(RibIR::CreateFunctionName( + site, + FunctionReferenceType::IndexedResourceMethod( + resource.clone(), + resource_params.len(), + method.clone(), + ), + )) + } + DynamicParsedFunctionReference::IndexedResourceStaticMethod { + resource, + resource_params, + method, + } => { + for param in resource_params { + stack.push(ExprState::from_expr(¶m.0)); + } + instructions.push(RibIR::CreateFunctionName( + site, + FunctionReferenceType::IndexedResourceStaticMethod( + resource.clone(), + resource_params.len(), + method.clone(), + ), + )) + } + DynamicParsedFunctionReference::IndexedResourceDrop { + resource, + resource_params, + } => { + for param in resource_params { + stack.push(ExprState::from_expr(¶m.0)); + } + instructions.push(RibIR::CreateFunctionName( + site, + FunctionReferenceType::IndexedResourceDrop( + resource.clone(), + resource_params.len(), + ), + )) + } } - CallType::VariantConstructor(variant_name) => { - instructions.push(RibIR::PushVariant( - variant_name.clone(), - convert_to_analysed_type_for(expr, inferred_type)?, - )); - } - CallType::EnumConstructor(enmum_name) => { - instructions.push(RibIR::PushEnum( - enmum_name.clone(), - convert_to_analysed_type_for(expr, inferred_type)?, - )); + for expr in arguments.iter().rev() { + stack.push(ExprState::from_expr(expr)); } + + instructions.push(RibIR::InvokeFunction(arguments.len(), function_result_type)); } - } + + CallType::VariantConstructor(variant_name) => { + instructions.push(RibIR::PushVariant( + variant_name.clone(), + convert_to_analysed_type_for(expr, inferred_type)?, + )); + } + CallType::EnumConstructor(enmum_name) => { + instructions.push(RibIR::PushEnum( + enmum_name.clone(), + convert_to_analysed_type_for(expr, inferred_type)?, + )); + } + }, Expr::Flags(flag_values, inferred_type) => match inferred_type { InferredType::Flags(all_flags) => { @@ -380,6 +484,7 @@ mod internal { stack.push(ExprState::from_ir(RibIR::Label(else_ending_id.clone()))); } } + #[cfg(test)] mod compiler_tests { use super::*; diff --git a/golem-rib/src/compiler/ir.rs b/golem-rib/src/compiler/ir.rs index efb7c0d5c3..5c4d73f82c 100644 --- a/golem-rib/src/compiler/ir.rs +++ b/golem-rib/src/compiler/ir.rs @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -use crate::{AnalysedTypeWithUnit, ParsedFunctionName, VariableId}; +use crate::{AnalysedTypeWithUnit, ParsedFunctionName, ParsedFunctionSite, VariableId}; use bincode::{Decode, Encode}; use golem_api_grpc::proto::golem::rib::rib_ir::Instruction; use golem_api_grpc::proto::golem::rib::{ @@ -51,7 +51,8 @@ pub enum RibIR { Jump(InstructionId), Label(InstructionId), Deconstruct, - InvokeFunction(ParsedFunctionName, usize, AnalysedTypeWithUnit), + CreateFunctionName(ParsedFunctionSite, FunctionReferenceType), + InvokeFunction(usize, AnalysedTypeWithUnit), PushVariant(String, AnalysedType), // There is no arg size since the type of each variant case is only 1 from beginning PushEnum(String, AnalysedType), Throw(String), @@ -60,6 +61,19 @@ pub enum RibIR { Negate, } +#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Encode, Decode)] +pub enum FunctionReferenceType { + Function(String), + RawResourceConstructor(String), + RawResourceDrop(String), + RawResourceMethod(String, String), + RawResourceStaticMethod(String, String), + IndexedResourceConstructor(String, usize), + IndexedResourceMethod(String, usize, String), + IndexedResourceStaticMethod(String, usize, String), + IndexedResourceDrop(String, usize), +} + // Every instruction can have a unique ID, and the compiler // can assign this and label the start and end of byte code blocks. // This is more efficient than assigning index to every instruction and incrementing it diff --git a/golem-rib/src/expr.rs b/golem-rib/src/expr.rs index 3b7d6cf08d..b65d5b9c7b 100644 --- a/golem-rib/src/expr.rs +++ b/golem-rib/src/expr.rs @@ -17,7 +17,7 @@ use crate::function_name::ParsedFunctionName; use crate::parser::rib_expr::rib_program; use crate::parser::type_name::TypeName; use crate::type_registry::FunctionTypeRegistry; -use crate::{text, type_inference, InferredType, VariableId}; +use crate::{text, type_inference, DynamicParsedFunctionName, InferredType, VariableId}; use bincode::{Decode, Encode}; use combine::stream::position; use combine::EasyParser; @@ -30,7 +30,7 @@ use std::fmt::Display; use std::ops::Deref; use std::str::FromStr; -#[derive(Debug, Clone, PartialEq, Encode, Decode)] +#[derive(Debug, Clone, PartialEq, Eq, Encode, Decode)] pub enum Expr { Let(VariableId, Option, Box, InferredType), SelectField(Box, String, InferredType), @@ -256,9 +256,9 @@ impl Expr { cond } - pub fn call(parsed_fn_name: ParsedFunctionName, args: Vec) -> Self { + pub fn call(dynamic_parsed_fn_name: DynamicParsedFunctionName, args: Vec) -> Self { Expr::Call( - CallType::Function(parsed_fn_name), + CallType::Function(dynamic_parsed_fn_name), args, InferredType::Unknown, ) @@ -692,7 +692,7 @@ impl Expr { } } -#[derive(Debug, Clone, PartialEq, Encode, Decode)] +#[derive(Debug, Clone, PartialEq, Eq, Encode, Decode)] pub struct Number { pub value: f64, // Change to bigdecimal } @@ -721,7 +721,7 @@ impl Display for Number { } } -#[derive(Debug, Clone, PartialEq, Encode, Decode)] +#[derive(Debug, Clone, PartialEq, Eq, Encode, Decode)] pub struct MatchArm { pub arm_pattern: ArmPattern, pub arm_resolution_expr: Box, @@ -735,7 +735,7 @@ impl MatchArm { } } } -#[derive(Debug, Clone, PartialEq, Encode, Decode)] +#[derive(Debug, Clone, PartialEq, Eq, Encode, Decode)] pub enum ArmPattern { WildCard, As(String, Box), diff --git a/golem-rib/src/function_name.rs b/golem-rib/src/function_name.rs index 0b3f8af3dd..95ee0dd835 100644 --- a/golem-rib/src/function_name.rs +++ b/golem-rib/src/function_name.rs @@ -12,13 +12,16 @@ // See the License for the specific language governing permissions and // limitations under the License. +use crate::{text, CompilerOutput, Expr, Interpreter, RibInterpreterResult}; use bincode::{BorrowDecode, Decode, Encode}; use combine::stream::easy; use combine::EasyParser; use golem_wasm_ast::analysis::AnalysedType; +use golem_wasm_rpc::json::TypeAnnotatedValueJsonExtensions; use golem_wasm_rpc::protobuf::type_annotated_value::TypeAnnotatedValue; use golem_wasm_rpc::type_annotated_value_from_str; use golem_wasm_rpc::Value; +use poem_openapi::types::ToJSON; use semver::{BuildMetadata, Prerelease}; use serde::{Deserialize, Serialize}; use std::borrow::Cow; @@ -266,6 +269,122 @@ pub enum ParsedFunctionReference { }, } +#[derive(Debug, PartialEq, Eq, Clone, Encode, Decode)] +pub(crate) enum DynamicParsedFunctionReference { + Function { + function: String, + }, + RawResourceConstructor { + resource: String, + }, + RawResourceDrop { + resource: String, + }, + RawResourceMethod { + resource: String, + method: String, + }, + RawResourceStaticMethod { + resource: String, + method: String, + }, + IndexedResourceConstructor { + resource: String, + resource_params: Vec, + }, + IndexedResourceMethod { + resource: String, + resource_params: Vec, + method: String, + }, + IndexedResourceStaticMethod { + resource: String, + resource_params: Vec, + method: String, + }, + IndexedResourceDrop { + resource: String, + resource_params: Vec, + }, +} + +impl DynamicParsedFunctionReference { + fn to_static(&self) -> ParsedFunctionReference { + match self { + Self::Function { function } => ParsedFunctionReference::Function { + function: function.clone(), + }, + Self::RawResourceConstructor { resource } => { + ParsedFunctionReference::RawResourceConstructor { + resource: resource.clone(), + } + } + Self::RawResourceDrop { resource } => ParsedFunctionReference::RawResourceDrop { + resource: resource.clone(), + }, + Self::RawResourceMethod { resource, method } => { + ParsedFunctionReference::RawResourceMethod { + resource: resource.clone(), + method: method.clone(), + } + } + Self::RawResourceStaticMethod { resource, method } => { + ParsedFunctionReference::RawResourceStaticMethod { + resource: resource.clone(), + method: method.clone(), + } + } + Self::IndexedResourceConstructor { + resource, + resource_params, + } => ParsedFunctionReference::IndexedResourceConstructor { + resource: resource.clone(), + resource_params: resource_params + .iter() + .map(|param| text::to_raw_string(¶m.0)) + .collect(), + }, + Self::IndexedResourceMethod { + resource, + resource_params, + method, + } => ParsedFunctionReference::IndexedResourceMethod { + resource: resource.clone(), + resource_params: resource_params + .iter() + .map(|param| text::to_raw_string(¶m.0)) + .collect(), + method: method.clone(), + }, + Self::IndexedResourceStaticMethod { + resource, + resource_params, + method, + } => ParsedFunctionReference::IndexedResourceStaticMethod { + resource: resource.clone(), + resource_params: resource_params + .iter() + .map(|param| text::to_raw_string(¶m.0)) + .collect(), + method: method.clone(), + }, + Self::IndexedResourceDrop { + resource, + resource_params, + } => ParsedFunctionReference::IndexedResourceDrop { + resource: resource.clone(), + resource_params: resource_params + .iter() + .map(|param| text::to_raw_string(¶m.0)) + .collect(), + }, + } + } +} + +#[derive(Debug, PartialEq, Eq, Clone, Encode, Decode)] +pub struct ResourceParam(pub Expr); + impl Display for ParsedFunctionReference { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { let function_name = match self { @@ -598,6 +717,51 @@ pub struct ParsedFunctionName { pub function: ParsedFunctionReference, } +#[derive(Debug, PartialEq, Eq, Clone, Encode, Decode)] +pub(crate) struct DynamicParsedFunctionName { + pub site: ParsedFunctionSite, + pub function: DynamicParsedFunctionReference, +} + +impl TryFrom for ParsedFunctionName { + type Error = String; + + fn try_from(value: DynamicParsedFunctionName) -> Result { + Ok(ParsedFunctionName { + site: value.site, + function: value.function.try_into()?, + }) + } +} + +impl DynamicParsedFunctionName { + pub fn parse(name: impl AsRef) -> Result { + let name = name.as_ref(); + + let mut parser = crate::parser::call::function_name(); + + let result: Result<(DynamicParsedFunctionName, &str), easy::ParseError<&str>> = + parser.easy_parse(name); + + match result { + Ok((parsed, _)) => Ok(parsed), + Err(error) => { + let error_message = error + .map_position(|p| p.translate_position(name)) + .to_string(); + Err(error_message) + } + } + } + + fn to_static(&self) -> ParsedFunctionName { + ParsedFunctionName { + site: self.site.clone(), + function: self.function.to_static(), + } + } +} + impl Serialize for ParsedFunctionName { fn serialize(&self, serializer: S) -> Result { let function_name = self.to_string(); @@ -651,7 +815,7 @@ impl ParsedFunctionName { let mut parser = crate::parser::call::function_name(); - let result: Result<(ParsedFunctionName, &str), easy::ParseError<&str>> = + let result: Result<(DynamicParsedFunctionName, &str), easy::ParseError<&str>> = parser.easy_parse(name); match result { diff --git a/golem-rib/src/interpreter/env.rs b/golem-rib/src/interpreter/env.rs index 6a33817bf3..3afe7ece61 100644 --- a/golem-rib/src/interpreter/env.rs +++ b/golem-rib/src/interpreter/env.rs @@ -27,7 +27,7 @@ pub struct InterpreterEnv { pub type RibFunctionInvoke = Arc< dyn Fn( - ParsedFunctionName, + String, Vec, ) -> Pin> + Send>> + Send @@ -56,7 +56,7 @@ impl InterpreterEnv { pub fn invoke_worker_function_async( &self, - function_name: ParsedFunctionName, + function_name: String, args: Vec, ) -> Pin> + Send>> { (self.call_worker_function_async)(function_name, args) diff --git a/golem-rib/src/interpreter/rib_interpreter.rs b/golem-rib/src/interpreter/rib_interpreter.rs index 90c38928c6..2d1c185b13 100644 --- a/golem-rib/src/interpreter/rib_interpreter.rs +++ b/golem-rib/src/interpreter/rib_interpreter.rs @@ -135,8 +135,12 @@ impl Interpreter { internal::run_select_index_instruction(&mut self.stack, index)?; } - RibIR::InvokeFunction(parsed_function_name, arity, _) => { - internal::run_call_instruction(parsed_function_name, arity, self).await?; + RibIR::CreateFunctionName(site, function_type) => { + internal::run_create_function_name_instruction(site, function_type, self)?; + } + + RibIR::InvokeFunction(arity, _) => { + internal::run_call_instruction(arity, self).await?; } RibIR::PushVariant(variant_name, analysed_type) => { @@ -210,13 +214,16 @@ mod internal { use crate::interpreter::result::RibInterpreterResult; use crate::interpreter::stack::InterpreterStack; use crate::{ - GetLiteralValue, InstructionId, Interpreter, ParsedFunctionName, RibIR, VariableId, + FunctionReferenceType, GetLiteralValue, InstructionId, Interpreter, ParsedFunctionName, + ParsedFunctionReference, ParsedFunctionSite, RibIR, VariableId, }; use golem_wasm_ast::analysis::AnalysedType; use golem_wasm_ast::analysis::TypeResult; use golem_wasm_rpc::protobuf::type_annotated_value::TypeAnnotatedValue; use golem_wasm_rpc::protobuf::typed_result::ResultValue; use golem_wasm_rpc::protobuf::{NameValuePair, TypedRecord, TypedTuple}; + use golem_wasm_rpc::type_annotated_value_to_string; + use poem_openapi::types::ToJSON; use std::collections::VecDeque; use std::ops::Deref; @@ -559,9 +566,202 @@ mod internal { } } + pub(crate) fn run_create_function_name_instruction( + site: ParsedFunctionSite, + function_type: FunctionReferenceType, + interpreter: &mut Interpreter, + ) -> Result<(), String> { + match function_type { + FunctionReferenceType::Function(parsed_fn_name) => { + let parsed_function_name = ParsedFunctionName { + site, + function: ParsedFunctionReference::Function { + function: parsed_fn_name, + }, + }; + + interpreter + .stack + .push_val(TypeAnnotatedValue::Str(parsed_function_name.to_string())); + } + + FunctionReferenceType::RawResourceConstructor(resource) => { + let parsed_function_name = ParsedFunctionName { + site, + function: ParsedFunctionReference::RawResourceConstructor { resource }, + }; + + interpreter + .stack + .push_val(TypeAnnotatedValue::Str(parsed_function_name.to_string())); + } + FunctionReferenceType::RawResourceDrop(resource) => { + let parsed_function_name = ParsedFunctionName { + site, + function: ParsedFunctionReference::RawResourceDrop { resource }, + }; + + interpreter + .stack + .push_val(TypeAnnotatedValue::Str(parsed_function_name.to_string())); + } + FunctionReferenceType::RawResourceMethod(resource, meethod) => { + let parsed_function_name = ParsedFunctionName { + site, + function: ParsedFunctionReference::RawResourceMethod { resource, method }, + }; + + interpreter + .stack + .push_val(TypeAnnotatedValue::Str(parsed_function_name.to_string())); + } + FunctionReferenceType::RawResourceStaticMethod(resource, method) => { + let parsed_function_name = ParsedFunctionName { + site, + function: ParsedFunctionReference::RawResourceStaticMethod { resource, method }, + }; + + interpreter + .stack + .push_val(TypeAnnotatedValue::Str(parsed_function_name.to_string())); + } + FunctionReferenceType::IndexedResourceConstructor(resource, resource_params_size) => { + let last_n_elements = interpreter + .stack + .pop_n(resource_params_size) + .ok_or("Failed to get values from the stack".to_string())?; + + let type_anntoated_values = last_n_elements + .iter() + .map(|interpreter_result| { + interpreter_result + .get_val() + .ok_or("Failed to get value from the stack".to_string()) + }) + .collect::, String>>()?; + + let parsed_function_name = ParsedFunctionName { + site, + function: ParsedFunctionReference::IndexedResourceConstructor { + resource, + resource_params: type_anntoated_values + .iter() + .map(type_annotated_value_to_string) + .collect()?, + }, + }; + + interpreter + .stack + .push_val(TypeAnnotatedValue::Str(parsed_function_name.to_string())); + } + FunctionReferenceType::IndexedResourceMethod( + resource, + resource_params_size, + method, + ) => { + let last_n_elements = interpreter + .stack + .pop_n(resource_params_size) + .ok_or("Failed to get values from the stack".to_string())?; + + let type_anntoated_values = last_n_elements + .iter() + .map(|interpreter_result| { + interpreter_result + .get_val() + .ok_or("Failed to get value from the stack".to_string()) + }) + .collect::, String>>()?; + + let parsed_function_name = ParsedFunctionName { + site, + function: ParsedFunctionReference::IndexedResourceMethod { + resource, + resource_params: type_anntoated_values + .iter() + .map(type_annotated_value_to_string) + .collect()?, + method, + }, + }; + + interpreter + .stack + .push_val(TypeAnnotatedValue::Str(parsed_function_name.to_string())); + } + FunctionReferenceType::IndexedResourceStaticMethod( + resource, + resource_params_size, + method, + ) => { + let last_n_elements = interpreter + .stack + .pop_n(resource_params_size) + .ok_or("Failed to get values from the stack".to_string())?; + + let type_anntoated_values = last_n_elements + .iter() + .map(|interpreter_result| { + interpreter_result + .get_val() + .ok_or("Failed to get value from the stack".to_string()) + }) + .collect::, String>>()?; + + let parsed_function_name = ParsedFunctionName { + site, + function: ParsedFunctionReference::IndexedResourceStaticMethod { + resource, + resource_params: type_anntoated_values + .iter() + .map(type_annotated_value_to_string) + .collect()?, + method, + }, + }; + + interpreter + .stack + .push_val(TypeAnnotatedValue::Str(parsed_function_name.to_string())); + } + FunctionReferenceType::IndexedResourceDrop(resource, resource_params) => { + let last_n_elements = interpreter + .stack + .pop_n(resource_params) + .ok_or("Failed to get values from the stack".to_string())?; + + let type_anntoated_values = last_n_elements + .iter() + .map(|interpreter_result| { + interpreter_result + .get_val() + .ok_or("Failed to get value from the stack".to_string()) + }) + .collect::, String>>()?; + + let parsed_function_name = ParsedFunctionName { + site, + function: ParsedFunctionReference::IndexedResourceDrop { + resource, + resource_params: type_anntoated_values + .iter() + .map(type_annotated_value_to_string) + .collect()?, + }, + }; + + interpreter + .stack + .push_val(TypeAnnotatedValue::Str(parsed_function_name.to_string())); + } + } + + Ok(()) + } + // Separate variant pub(crate) async fn run_call_instruction( - parsed_function_name: ParsedFunctionName, argument_size: usize, interpreter: &mut Interpreter, ) -> Result<(), String> { @@ -579,9 +779,14 @@ mod internal { }) .collect::, String>>()?; + let function_name = interpreter + .stack + .pop_str() + .ok_or("Failed to get a function name from the stack".to_string())?; + let result = interpreter .env - .invoke_worker_function_async(parsed_function_name, type_anntoated_values) + .invoke_worker_function_async(function_name, type_anntoated_values) .await?; let interpreter_result = match result { diff --git a/golem-rib/src/interpreter/stack.rs b/golem-rib/src/interpreter/stack.rs index eda6ef4de9..b42a5f59c0 100644 --- a/golem-rib/src/interpreter/stack.rs +++ b/golem-rib/src/interpreter/stack.rs @@ -63,6 +63,13 @@ impl InterpreterStack { Some(results) } + pub fn pop_str(&mut self) -> Option { + self.pop_val().and_then(|v| match v { + TypeAnnotatedValue::Str(s) => Some(s), + _ => None, + }) + } + pub fn pop_val(&mut self) -> Option { self.stack.pop().and_then(|v| v.get_val()) } diff --git a/golem-rib/src/parser/call.rs b/golem-rib/src/parser/call.rs index d07c6e18b8..2e2800d5d0 100644 --- a/golem-rib/src/parser/call.rs +++ b/golem-rib/src/parser/call.rs @@ -12,12 +12,14 @@ // See the License for the specific language governing permissions and // limitations under the License. +use crate::{DynamicParsedFunctionName, DynamicParsedFunctionReference, ResourceParam}; use combine::error::Commit; use combine::parser::char::{alpha_num, string}; use combine::parser::char::{char, spaces}; use combine::parser::repeat::take_until; -use combine::sep_by; +use combine::stream::position; use combine::{any, attempt, between, choice, many1, optional, parser, token, ParseError, Parser}; +use combine::{sep_by, EasyParser}; use crate::expr::Expr; use crate::function_name::{ @@ -46,11 +48,7 @@ where .message("Invalid function call") } -// TODO; Reusing function_name between Rib and internals of GOLEM may be a surface level requirement -// as users can form function name in various other ways. -// Example: Arguments to a resource can be partial because they may come from request parameters -// and these are not represented using the current structure of ParsedFunctionName -pub fn function_name() -> impl Parser +pub fn function_name() -> impl Parser where Input: combine::Stream, RibParseError: Into< @@ -81,7 +79,11 @@ where nesting += 1; current_param.push(next_char); } else if next_char == ',' && nesting == 1 { - result.push(current_param.trim().to_string()); + let (expr, _) = rib_expr() + .easy_parse(position::Stream::new(current_param.trim())) + .into_result()?; + + result.push(expr); current_param.clear(); } else { current_param.push(next_char); @@ -94,7 +96,11 @@ where } if !current_param.is_empty() { - result.push(current_param.trim().to_string()); + let expr = rib_expr() + .easy_parse(position::Stream::new(¤t_param)) + .into_result()?; + + result.push(expr.0); } Ok((result, result_committed.unwrap())) @@ -112,44 +118,55 @@ where }) .message("version"); - let single_function = identifier().map(|id| ParsedFunctionReference::Function { function: id }); + let single_function = + identifier().map(|id| DynamicParsedFunctionReference::Function { function: id }); let indexed_resource_syntax = || (identifier(), token('(').with(capture_resource_params())); let indexed_constructor_syntax = (indexed_resource_syntax(), token('.'), string("new")).map( - |((resource, resource_params), _, _)| ParsedFunctionReference::IndexedResourceConstructor { - resource, - resource_params, + |((resource, resource_params), _, _)| { + DynamicParsedFunctionReference::IndexedResourceConstructor { + resource, + resource_params: resource_params.into_iter().map(ResourceParam).collect(), + } }, ); let indexed_drop_syntax = (indexed_resource_syntax(), token('.'), string("drop")).map( - |((resource, resource_params), _, _)| ParsedFunctionReference::IndexedResourceDrop { + |((resource, resource_params), _, _)| DynamicParsedFunctionReference::IndexedResourceDrop { resource, - resource_params, + resource_params: resource_params.into_iter().map(ResourceParam).collect(), }, ); let indexed_method_syntax = (indexed_resource_syntax(), token('.'), identifier()).map( - |((resource, resource_params), _, method)| ParsedFunctionReference::IndexedResourceMethod { - resource, - resource_params, - method, + |((resource, resource_params), _, method)| { + DynamicParsedFunctionReference::IndexedResourceMethod { + resource, + resource_params: resource_params.into_iter().map(ResourceParam).collect(), + method, + } }, ); let raw_constructor_syntax = (identifier(), token('.'), string("new")) - .map(|(resource, _, _)| ParsedFunctionReference::RawResourceConstructor { resource }) - .or((string("[constructor]"), identifier()) - .map(|(_, resource)| ParsedFunctionReference::RawResourceConstructor { resource })); + .map(|(resource, _, _)| DynamicParsedFunctionReference::RawResourceConstructor { resource }) + .or( + (string("[constructor]"), identifier()).map(|(_, resource)| { + DynamicParsedFunctionReference::RawResourceConstructor { resource } + }), + ); let raw_drop_syntax = (identifier(), token('.'), string("drop")) - .map(|(resource, _, _)| ParsedFunctionReference::RawResourceDrop { resource }) + .map(|(resource, _, _)| DynamicParsedFunctionReference::RawResourceDrop { resource }) .or((string("[drop]"), identifier()) - .map(|(_, resource)| ParsedFunctionReference::RawResourceDrop { resource })); + .map(|(_, resource)| DynamicParsedFunctionReference::RawResourceDrop { resource })); let raw_method_syntax = (identifier(), token('.'), identifier()) .map( - |(resource, _, method)| ParsedFunctionReference::RawResourceMethod { resource, method }, + |(resource, _, method)| DynamicParsedFunctionReference::RawResourceMethod { + resource, + method, + }, ) .or( (string("[method]"), identifier(), token('.'), identifier()).map( - |(_, resource, _, method)| ParsedFunctionReference::RawResourceMethod { + |(_, resource, _, method)| DynamicParsedFunctionReference::RawResourceMethod { resource, method, }, @@ -157,7 +174,7 @@ where ); let raw_static_method_syntax = (string("[static]"), identifier(), token('.'), identifier()) .map( - |(_, resource, _, method)| ParsedFunctionReference::RawResourceStaticMethod { + |(_, resource, _, method)| DynamicParsedFunctionReference::RawResourceStaticMethod { resource, method, }, @@ -194,17 +211,18 @@ where }, None => ParsedFunctionSite::Interface { name: iface }, }; - ParsedFunctionName { site, function } + DynamicParsedFunctionName { site, function } }), ) - .or(identifier().map(|id| ParsedFunctionName { + .or(identifier().map(|id| DynamicParsedFunctionName { site: ParsedFunctionSite::Global, - function: ParsedFunctionReference::Function { function: id }, + function: DynamicParsedFunctionReference::Function { function: id }, })) } #[cfg(test)] mod function_call_tests { + use crate::{DynamicParsedFunctionName, DynamicParsedFunctionReference, ResourceParam}; use combine::EasyParser; use crate::expr::Expr; @@ -219,9 +237,9 @@ mod function_call_tests { let result = rib_expr().easy_parse(input); let expected = Ok(( Expr::call( - ParsedFunctionName { + DynamicParsedFunctionName { site: ParsedFunctionSite::Global, - function: ParsedFunctionReference::Function { + function: DynamicParsedFunctionReference::Function { function: "foo".to_string(), }, }, @@ -240,9 +258,9 @@ mod function_call_tests { let expected = Ok(( Expr::call( - ParsedFunctionName { + DynamicParsedFunctionName { site: ParsedFunctionSite::Global, - function: ParsedFunctionReference::Function { + function: DynamicParsedFunctionReference::Function { function: "foo".to_string(), }, }, @@ -259,9 +277,9 @@ mod function_call_tests { let result = rib_expr().easy_parse(input); let expected = Ok(( Expr::call( - ParsedFunctionName { + DynamicParsedFunctionName { site: ParsedFunctionSite::Global, - function: ParsedFunctionReference::Function { + function: DynamicParsedFunctionReference::Function { function: "foo".to_string(), }, }, @@ -278,9 +296,9 @@ mod function_call_tests { let result = rib_expr().easy_parse(input); let expected = Ok(( Expr::call( - ParsedFunctionName { + DynamicParsedFunctionName { site: ParsedFunctionSite::Global, - function: ParsedFunctionReference::Function { + function: DynamicParsedFunctionReference::Function { function: "foo".to_string(), }, }, @@ -301,9 +319,9 @@ mod function_call_tests { let result = rib_expr().easy_parse(input); let expected = Ok(( Expr::call( - ParsedFunctionName { + DynamicParsedFunctionName { site: ParsedFunctionSite::Global, - function: ParsedFunctionReference::Function { + function: DynamicParsedFunctionReference::Function { function: "foo".to_string(), }, }, @@ -325,9 +343,9 @@ mod function_call_tests { let result = rib_expr().easy_parse(input); let expected = Ok(( Expr::call( - ParsedFunctionName { + DynamicParsedFunctionName { site: ParsedFunctionSite::Global, - function: ParsedFunctionReference::Function { + function: DynamicParsedFunctionReference::Function { function: "foo".to_string(), }, }, @@ -350,9 +368,9 @@ mod function_call_tests { let result = rib_expr().easy_parse(input); let expected = Ok(( Expr::call( - ParsedFunctionName { + DynamicParsedFunctionName { site: ParsedFunctionSite::Global, - function: ParsedFunctionReference::Function { + function: DynamicParsedFunctionReference::Function { function: "foo".to_string(), }, }, @@ -376,9 +394,9 @@ mod function_call_tests { let result = rib_expr().easy_parse(input); let expected = Ok(( Expr::call( - ParsedFunctionName { + DynamicParsedFunctionName { site: ParsedFunctionSite::Global, - function: ParsedFunctionReference::Function { + function: DynamicParsedFunctionReference::Function { function: "foo".to_string(), }, }, @@ -398,9 +416,9 @@ mod function_call_tests { let result = rib_expr().easy_parse(input); let expected = Ok(( Expr::call( - ParsedFunctionName { + DynamicParsedFunctionName { site: ParsedFunctionSite::Global, - function: ParsedFunctionReference::Function { + function: DynamicParsedFunctionReference::Function { function: "foo".to_string(), }, }, @@ -420,9 +438,9 @@ mod function_call_tests { let result = rib_expr().easy_parse(input); let expected = Ok(( Expr::call( - ParsedFunctionName { + DynamicParsedFunctionName { site: ParsedFunctionSite::Global, - function: ParsedFunctionReference::Function { + function: DynamicParsedFunctionReference::Function { function: "foo".to_string(), }, }, @@ -442,9 +460,9 @@ mod function_call_tests { let result = rib_expr().easy_parse(input); let expected = Ok(( Expr::call( - ParsedFunctionName { + DynamicParsedFunctionName { site: ParsedFunctionSite::Global, - function: ParsedFunctionReference::Function { + function: DynamicParsedFunctionReference::Function { function: "foo".to_string(), }, }, @@ -465,9 +483,9 @@ mod function_call_tests { let result = rib_expr().easy_parse(input); let expected = Ok(( Expr::call( - ParsedFunctionName { + DynamicParsedFunctionName { site: ParsedFunctionSite::Global, - function: ParsedFunctionReference::Function { + function: DynamicParsedFunctionReference::Function { function: "foo".to_string(), }, }, @@ -487,9 +505,9 @@ mod function_call_tests { let result = rib_expr().easy_parse(input); let expected = Ok(( Expr::call( - ParsedFunctionName { + DynamicParsedFunctionName { site: ParsedFunctionSite::Global, - function: ParsedFunctionReference::Function { + function: DynamicParsedFunctionReference::Function { function: "foo".to_string(), }, }, @@ -509,9 +527,9 @@ mod function_call_tests { let result = rib_expr().easy_parse(input); let expected = Ok(( Expr::call( - ParsedFunctionName { + DynamicParsedFunctionName { site: ParsedFunctionSite::Global, - function: ParsedFunctionReference::Function { + function: DynamicParsedFunctionReference::Function { function: "foo".to_string(), }, }, @@ -531,9 +549,9 @@ mod function_call_tests { let result = rib_expr().easy_parse(input); let expected = Ok(( Expr::call( - ParsedFunctionName { + DynamicParsedFunctionName { site: ParsedFunctionSite::Global, - function: ParsedFunctionReference::Function { + function: DynamicParsedFunctionReference::Function { function: "foo".to_string(), }, }, @@ -553,9 +571,9 @@ mod function_call_tests { let result = rib_expr().easy_parse(input); let expected = Ok(( Expr::call( - ParsedFunctionName { + DynamicParsedFunctionName { site: ParsedFunctionSite::Global, - function: ParsedFunctionReference::Function { + function: DynamicParsedFunctionReference::Function { function: "foo".to_string(), }, }, @@ -575,9 +593,9 @@ mod function_call_tests { let result = rib_expr().easy_parse(input); let expected = Ok(( Expr::call( - ParsedFunctionName { + DynamicParsedFunctionName { site: ParsedFunctionSite::Global, - function: ParsedFunctionReference::Function { + function: DynamicParsedFunctionReference::Function { function: "foo".to_string(), }, }, @@ -594,11 +612,11 @@ mod function_call_tests { let result = rib_expr().easy_parse(input); let expected = Ok(( Expr::call( - ParsedFunctionName { + DynamicParsedFunctionName { site: ParsedFunctionSite::Interface { name: "interface".to_string(), }, - function: ParsedFunctionReference::Function { + function: DynamicParsedFunctionReference::Function { function: "fn1".to_string(), }, }, @@ -615,14 +633,14 @@ mod function_call_tests { let result = rib_expr().easy_parse(input); let expected = Ok(( Expr::call( - ParsedFunctionName { + DynamicParsedFunctionName { site: ParsedFunctionSite::PackagedInterface { namespace: "ns".to_string(), package: "name".to_string(), interface: "interface".to_string(), version: None, }, - function: ParsedFunctionReference::Function { + function: DynamicParsedFunctionReference::Function { function: "fn1".to_string(), }, }, @@ -639,14 +657,14 @@ mod function_call_tests { let result = rib_expr().easy_parse(input); let expected = Ok(( Expr::call( - ParsedFunctionName { + DynamicParsedFunctionName { site: ParsedFunctionSite::PackagedInterface { namespace: "wasi".to_string(), package: "cli".to_string(), interface: "run".to_string(), version: Some(SemVer(semver::Version::new(0, 2, 0))), }, - function: ParsedFunctionReference::Function { + function: DynamicParsedFunctionReference::Function { function: "run".to_string(), }, }, @@ -663,14 +681,14 @@ mod function_call_tests { let result = rib_expr().easy_parse(input); let expected = Ok(( Expr::call( - ParsedFunctionName { + DynamicParsedFunctionName { site: ParsedFunctionSite::PackagedInterface { namespace: "ns".to_string(), package: "name".to_string(), interface: "interface".to_string(), version: None, }, - function: ParsedFunctionReference::RawResourceConstructor { + function: DynamicParsedFunctionReference::RawResourceConstructor { resource: "resource1".to_string(), }, }, @@ -687,14 +705,14 @@ mod function_call_tests { let result = rib_expr().easy_parse(input); let expected = Ok(( Expr::call( - ParsedFunctionName { + DynamicParsedFunctionName { site: ParsedFunctionSite::PackagedInterface { namespace: "ns".to_string(), package: "name".to_string(), interface: "interface".to_string(), version: None, }, - function: ParsedFunctionReference::RawResourceConstructor { + function: DynamicParsedFunctionReference::RawResourceConstructor { resource: "resource1".to_string(), }, }, @@ -711,14 +729,14 @@ mod function_call_tests { let result = rib_expr().easy_parse(input); let expected = Ok(( Expr::call( - ParsedFunctionName { + DynamicParsedFunctionName { site: ParsedFunctionSite::PackagedInterface { namespace: "ns".to_string(), package: "name".to_string(), interface: "interface".to_string(), version: None, }, - function: ParsedFunctionReference::IndexedResourceConstructor { + function: DynamicParsedFunctionReference::IndexedResourceConstructor { resource: "resource1".to_string(), resource_params: vec![], }, @@ -738,19 +756,19 @@ mod function_call_tests { let result = rib_expr().easy_parse(input); let expected = Ok(( Expr::call( - ParsedFunctionName { + DynamicParsedFunctionName { site: ParsedFunctionSite::PackagedInterface { namespace: "ns".to_string(), package: "name".to_string(), interface: "interface".to_string(), version: None, }, - function: ParsedFunctionReference::IndexedResourceConstructor { + function: DynamicParsedFunctionReference::IndexedResourceConstructor { resource: "resource1".to_string(), resource_params: vec![ - "\"hello\"".to_string(), - "1".to_string(), - "true".to_string(), + ResourceParam(Expr::literal("hello")), + ResourceParam(Expr::number(1f64)), + ResourceParam(Expr::boolean(true)), ], }, }, @@ -768,18 +786,29 @@ mod function_call_tests { let result = rib_expr().easy_parse(input); let expected = Ok(( Expr::call( - ParsedFunctionName { + DynamicParsedFunctionName { site: ParsedFunctionSite::PackagedInterface { namespace: "ns".to_string(), package: "name".to_string(), interface: "interface".to_string(), version: None, }, - function: ParsedFunctionReference::IndexedResourceConstructor { + function: DynamicParsedFunctionReference::IndexedResourceConstructor { resource: "resource1".to_string(), resource_params: vec![ - "\"hello\"".to_string(), - "{ field-a: some(1) }".to_string(), + ResourceParam(Expr::literal("hello")), + ResourceParam(Expr::record(vec![( + "field-a".to_string(), + Expr::call( + DynamicParsedFunctionName { + site: ParsedFunctionSite::Global, + function: DynamicParsedFunctionReference::Function { + function: "some".to_string(), + }, + }, + vec![Expr::number(1f64)], + ), + )])), ], }, }, @@ -795,14 +824,14 @@ mod function_call_tests { let input = "ns:name/interface.{resource1.do-something}({bar, baz})"; let result = Expr::from_text(input).unwrap(); let expected = Expr::call( - ParsedFunctionName { + DynamicParsedFunctionName { site: ParsedFunctionSite::PackagedInterface { namespace: "ns".to_string(), package: "name".to_string(), interface: "interface".to_string(), version: None, }, - function: ParsedFunctionReference::RawResourceMethod { + function: DynamicParsedFunctionReference::RawResourceMethod { resource: "resource1".to_string(), method: "do-something".to_string(), }, @@ -818,14 +847,14 @@ mod function_call_tests { let result = rib_expr().easy_parse(input); let expected = Ok(( Expr::call( - ParsedFunctionName { + DynamicParsedFunctionName { site: ParsedFunctionSite::PackagedInterface { namespace: "ns".to_string(), package: "name".to_string(), interface: "interface".to_string(), version: None, }, - function: ParsedFunctionReference::RawResourceMethod { + function: DynamicParsedFunctionReference::RawResourceMethod { resource: "resource1".to_string(), method: "do-something".to_string(), }, @@ -844,14 +873,14 @@ mod function_call_tests { let result = rib_expr().easy_parse(input); let expected = Ok(( Expr::call( - ParsedFunctionName { + DynamicParsedFunctionName { site: ParsedFunctionSite::PackagedInterface { namespace: "ns".to_string(), package: "name".to_string(), interface: "interface".to_string(), version: None, }, - function: ParsedFunctionReference::RawResourceMethod { + function: DynamicParsedFunctionReference::RawResourceMethod { resource: "resource1".to_string(), method: "do-something-static".to_string(), }, @@ -869,14 +898,14 @@ mod function_call_tests { let result = rib_expr().easy_parse(input); let expected = Ok(( Expr::call( - ParsedFunctionName { + DynamicParsedFunctionName { site: ParsedFunctionSite::PackagedInterface { namespace: "ns".to_string(), package: "name".to_string(), interface: "interface".to_string(), version: None, }, - function: ParsedFunctionReference::RawResourceStaticMethod { + function: DynamicParsedFunctionReference::RawResourceStaticMethod { resource: "resource1".to_string(), method: "do-something-static".to_string(), }, @@ -894,14 +923,14 @@ mod function_call_tests { let result = rib_expr().easy_parse(input); let expected = Ok(( Expr::call( - ParsedFunctionName { + DynamicParsedFunctionName { site: ParsedFunctionSite::PackagedInterface { namespace: "ns".to_string(), package: "name".to_string(), interface: "interface".to_string(), version: None, }, - function: ParsedFunctionReference::RawResourceDrop { + function: DynamicParsedFunctionReference::RawResourceDrop { resource: "resource1".to_string(), }, }, @@ -918,14 +947,14 @@ mod function_call_tests { let result = rib_expr().easy_parse(input); let expected = Ok(( Expr::call( - ParsedFunctionName { + DynamicParsedFunctionName { site: ParsedFunctionSite::PackagedInterface { namespace: "ns".to_string(), package: "name".to_string(), interface: "interface".to_string(), version: None, }, - function: ParsedFunctionReference::IndexedResourceDrop { + function: DynamicParsedFunctionReference::IndexedResourceDrop { resource: "resource1".to_string(), resource_params: vec![], }, @@ -943,19 +972,19 @@ mod function_call_tests { let result = rib_expr().easy_parse(input); let expected = Ok(( Expr::call( - ParsedFunctionName { + DynamicParsedFunctionName { site: ParsedFunctionSite::PackagedInterface { namespace: "ns".to_string(), package: "name".to_string(), interface: "interface".to_string(), version: None, }, - function: ParsedFunctionReference::IndexedResourceDrop { + function: DynamicParsedFunctionReference::IndexedResourceDrop { resource: "resource1".to_string(), resource_params: vec![ - "\"hello\"".to_string(), - "1".to_string(), - "true".to_string(), + ResourceParam(Expr::literal("hello")), + ResourceParam(Expr::number(1f64)), + ResourceParam(Expr::boolean(true)), ], }, }, @@ -973,18 +1002,29 @@ mod function_call_tests { let result = rib_expr().easy_parse(input); let expected = Ok(( Expr::call( - ParsedFunctionName { + DynamicParsedFunctionName { site: ParsedFunctionSite::PackagedInterface { namespace: "ns".to_string(), package: "name".to_string(), interface: "interface".to_string(), version: None, }, - function: ParsedFunctionReference::IndexedResourceDrop { + function: DynamicParsedFunctionReference::IndexedResourceDrop { resource: "resource1".to_string(), resource_params: vec![ - "\"hello\"".to_string(), - "{ field-a: some(1) }".to_string(), + ResourceParam(Expr::literal("\"hello\"")), + ResourceParam(Expr::record(vec![( + "field-a".to_string(), + Expr::call( + DynamicParsedFunctionName { + site: ParsedFunctionSite::Global, + function: DynamicParsedFunctionReference::Function { + function: "some".to_string(), + }, + }, + vec![Expr::literal("1")], + ), + )])), ], }, }, @@ -1001,14 +1041,14 @@ mod function_call_tests { let result = rib_expr().easy_parse(input); let expected = Ok(( Expr::call( - ParsedFunctionName { + DynamicParsedFunctionName { site: ParsedFunctionSite::PackagedInterface { namespace: "ns".to_string(), package: "name".to_string(), interface: "interface".to_string(), version: None, }, - function: ParsedFunctionReference::RawResourceDrop { + function: DynamicParsedFunctionReference::RawResourceDrop { resource: "resource1".to_string(), }, }, diff --git a/golem-rib/src/text/mod.rs b/golem-rib/src/text/mod.rs index 18565ce3b7..99122b9283 100644 --- a/golem-rib/src/text/mod.rs +++ b/golem-rib/src/text/mod.rs @@ -26,6 +26,14 @@ pub fn to_string(expr: &Expr) -> Result { writer::write_expr(expr) } +// Writes Expr without any outer interpolation in all cases +// TODO; Once we avoid interpolation support (other than for concatenations, we need just `to_string` +// and avoid distinguishing it with `to_string`. Currently `to_string` writes expressions wrapped with interpolation +// unless they are literals/text concatenated string +pub fn to_raw_string(expr: &Expr) -> String { + writer::write_expr(expr).unwrap() +} + #[cfg(test)] mod record_tests { use crate::expr::*; diff --git a/golem-rib/src/text/writer.rs b/golem-rib/src/text/writer.rs index 9db0afae23..0e61945f1c 100644 --- a/golem-rib/src/text/writer.rs +++ b/golem-rib/src/text/writer.rs @@ -41,6 +41,15 @@ pub fn write_expr(expr: &Expr) -> Result { Ok(String::from_utf8(buf).unwrap_or_else(|err| panic!("invalid UTF-8: {err:?}"))) } +pub fn write_expr_without_interpolation(expr: &Expr) -> Result { + let mut buf = vec![]; + let mut writer = Writer::new(&mut buf); + + writer.write_expr(expr)?; + + Ok(String::from_utf8(buf).unwrap_or_else(|err| panic!("invalid UTF-8: {err:?}"))) +} + struct Writer { inner: W, } diff --git a/golem-worker-service-base/src/worker_bridge_execution/mod.rs b/golem-worker-service-base/src/worker_bridge_execution/mod.rs index 5d5d8c4496..f1d40301ec 100644 --- a/golem-worker-service-base/src/worker_bridge_execution/mod.rs +++ b/golem-worker-service-base/src/worker_bridge_execution/mod.rs @@ -11,7 +11,7 @@ pub use worker_request_executor::*; pub struct WorkerRequest { pub component_id: ComponentId, pub worker_name: String, - pub function_name: ParsedFunctionName, + pub function_name: String, pub function_params: Vec, pub idempotency_key: Option, } diff --git a/golem-worker-service/src/worker_bridge_request_executor.rs b/golem-worker-service/src/worker_bridge_request_executor.rs index a2ed73bb08..3f0e8b5509 100644 --- a/golem-worker-service/src/worker_bridge_request_executor.rs +++ b/golem-worker-service/src/worker_bridge_request_executor.rs @@ -92,7 +92,7 @@ mod internal { .invoke_and_await_function_json( &worker_id, worker_request_params.idempotency_key, - worker_request_params.function_name.to_string(), + worker_request_params.function_name, invoke_parameters, None, empty_worker_metadata(),