momento_functions/macros/
function_spawn.rs1#[macro_export]
26macro_rules! spawn {
27 ($spawn_handler: ident) => {
28 struct SpawnFunction;
29 momento_functions_wit::function_spawn::export_spawn_function!(SpawnFunction);
30
31 #[automatically_derived]
32 impl momento_functions_wit::function_spawn::exports::momento::functions::guest_function_spawn::Guest for SpawnFunction {
33 fn spawned(payload: Vec<u8>) {
34 $spawn_handler(payload)
35 }
36 }
37 };
38
39 ($post_handler: ident, $request: ident) => {
40 struct SpawnFunction;
41 momento_functions_wit::function_spawn::export_spawn_function!(SpawnFunction);
42
43 #[automatically_derived]
44 impl momento_functions_wit::function_spawn::exports::momento::functions::guest_function_spawn::Guest for SpawnFunction {
45 fn spawned(payload: Vec<u8>) {
46 let payload: $request = serde_json::from_slice(&payload).expect("payload is not valid json");
47 $post_handler(payload)
48 }
49 }
50 }
51}