Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(spell): update to new mailbox [NET-505] #1694

Merged
merged 7 commits into from
Jul 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ particle-execution = { path = "particle-execution" }
system-services = { path = "crates/system-services" }

# spell
fluence-spell-dtos = "=0.5.15"
fluence-spell-distro = "=0.5.15"
fluence-spell-dtos = "=0.5.16"
fluence-spell-distro = "=0.5.16"

# marine
fluence-app-service = {version = "=0.26.4-feat-wasm-backend-interface-update-b3cf050-636-1.0", registry = "fluence"}
Expand Down
8 changes: 4 additions & 4 deletions crates/nox-tests/tests/spells.rs
Original file line number Diff line number Diff line change
Expand Up @@ -901,7 +901,7 @@ async fn spell_timer_trigger_mailbox_test() {
(seq
(seq
(call %init_peer_id% ("getDataSrv" "spell_id") [] spell_id)
(call %init_peer_id% (spell_id "list_pop_string") ["trigger_mailbox"] trigger)
(call %init_peer_id% (spell_id "pop_mailbox") [] trigger)
)
(seq
(call %init_peer_id% ("json" "parse") [trigger.$.str] obj)
Expand Down Expand Up @@ -945,7 +945,7 @@ async fn spell_connection_pool_trigger_mailbox_test() {
(seq
(call %init_peer_id% ("getDataSrv" "spell_id") [] spell_id)
(seq
(call %init_peer_id% (spell_id "list_pop_string") ["trigger_mailbox"] trigger)
(call %init_peer_id% (spell_id "pop_mailbox") [] trigger)
(call %init_peer_id% ("run-console" "print") ["pop mailbox, trigger:" trigger])
)
)
Expand Down Expand Up @@ -1102,7 +1102,7 @@ async fn spell_update_config() {
r#"(seq
(seq
(call %init_peer_id% ("getDataSrv" "spell_id") [] spell_id)
(call %init_peer_id% (spell_id "list_pop_string") ["trigger_mailbox"] result)
(call %init_peer_id% (spell_id "pop_mailbox") [] result)
)
(call "{}" ("return" "") [result])
)"#,
Expand Down Expand Up @@ -1194,7 +1194,7 @@ async fn spell_update_config_stopped_spell() {
r#"(seq
(seq
(call %init_peer_id% ("getDataSrv" "spell_id") [] spell_id)
(call %init_peer_id% (spell_id "list_pop_string") ["trigger_mailbox"] result)
(call %init_peer_id% (spell_id "pop_mailbox") [] result)
)
(call "{}" ("return" "") [result])
)"#,
Expand Down
25 changes: 21 additions & 4 deletions sorcerer/src/script_executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,15 +133,32 @@ impl Sorcerer {
let func_outcome = self.services.call_function(
worker_id,
&event.spell_id,
"list_push_string",
vec![json!("trigger_mailbox"), json!(serialized_event)],
"push_mailbox",
vec![json!(serialized_event)],
None,
worker_id,
self.spell_script_particle_ttl,
);

process_func_outcome::<UnitValue>(func_outcome, &event.spell_id, "list_push_string")
.map(drop)
match process_func_outcome::<UnitValue>(func_outcome, &event.spell_id, "push_mailbox") {
Ok(_) => Ok(()),
Err(err) => {
log::warn!("Error on push_mailbox for spell {}: {}. Trying a fallback with list_push_string", event.spell_id, err);

// fallback for older spell versions
let func_outcome = self.services.call_function(
worker_id,
&event.spell_id,
"list_push_string",
vec![json!("trigger_mailbox"), json!(serialized_event)],
None,
worker_id,
self.spell_script_particle_ttl,
);
process_func_outcome::<UnitValue>(func_outcome, &event.spell_id, "list_push_string")
.map(drop)
}
}
}

pub async fn execute_script(&self, event: TriggerEvent) {
Expand Down
Loading