Skip to content

feat: add option to emit response event on each callback & RunScriptCallback command for "once-off" callbacks #403

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

Merged
merged 1 commit into from
Apr 1, 2025

Conversation

makspll
Copy link
Owner

@makspll makspll commented Mar 31, 2025

Summary

Largely, this is a refactor of the commands module, we now use a shared command RunScriptCallback to initiate internal callbacks. This command can also be used by consumers of BMS removing the need to have a full blown system to initiate one off callbacks.

At the same time, this adds a trigger_response field to the script callback event, when this is set to true:

  • Event handlers will emit a ScriptCallbackResponseEvent with the response payload from the script
  • Just as the RunScriptCallback command will do the same

This should give users more flexibility in running "once-off" callbacks, especially if they require scripts to output something from them. At the moment the best bet is to either:

  • have an event handler in a temporary schedule
  • run custom logic with event handler state

@makspll makspll added the needs documentation For features or changes which still need changes in the book label Mar 31, 2025
@makspll makspll changed the title feat: add option to emit callback response event on each callback & RunScriptCallback command feat: add option to emit response event on each callback & RunScriptCallback command for "once-off" callbacks Mar 31, 2025
Copy link
Contributor

github-actions bot commented Mar 31, 2025

🐰 Bencher Report

Branchfeat/response-callbacks
Testbedlinux-gha
Click to view all benchmark results
BenchmarkLatencyBenchmark Result
nanoseconds (ns)
(Result Δ%)
Upper Boundary
nanoseconds (ns)
(Limit %)
component/access Lua📈 view plot
🚷 view threshold
3,337.30 ns
(-33.15%)Baseline: 4,992.06 ns
6,438.08 ns
(51.84%)
component/access Rhai📈 view plot
🚷 view threshold
5,238.00 ns
(-22.72%)Baseline: 6,778.29 ns
8,158.97 ns
(64.20%)
component/get Lua📈 view plot
🚷 view threshold
2,039.50 ns
(-30.41%)Baseline: 2,930.64 ns
3,590.92 ns
(56.80%)
component/get Rhai📈 view plot
🚷 view threshold
3,983.90 ns
(-19.02%)Baseline: 4,919.58 ns
6,092.42 ns
(65.39%)
conversions/Mut::from📈 view plot
🚷 view threshold
95.03 ns
(-33.32%)Baseline: 142.50 ns
256.18 ns
(37.09%)
conversions/Ref::from📈 view plot
🚷 view threshold
96.90 ns
(-31.20%)Baseline: 140.85 ns
253.62 ns
(38.21%)
conversions/ScriptValue::List📈 view plot
🚷 view threshold
286.10 ns
(-58.49%)Baseline: 689.23 ns
1,056.11 ns
(27.09%)
conversions/ScriptValue::Map📈 view plot
🚷 view threshold
1,209.00 ns
(-29.22%)Baseline: 1,708.08 ns
2,241.86 ns
(53.93%)
conversions/ScriptValue::Reference::from_into📈 view plot
🚷 view threshold
38.68 ns
(-10.63%)Baseline: 43.29 ns
54.75 ns
(70.65%)
conversions/Val::from_into📈 view plot
🚷 view threshold
264.90 ns
(-22.23%)Baseline: 340.60 ns
465.36 ns
(56.92%)
function/call 4 args Lua📈 view plot
🚷 view threshold
1,596.60 ns
(-24.85%)Baseline: 2,124.47 ns
2,532.84 ns
(63.04%)
function/call 4 args Rhai📈 view plot
🚷 view threshold
1,385.40 ns
(-24.93%)Baseline: 1,845.42 ns
2,223.57 ns
(62.31%)
function/call Lua📈 view plot
🚷 view threshold
225.49 ns
(-20.27%)Baseline: 282.83 ns
340.25 ns
(66.27%)
function/call Rhai📈 view plot
🚷 view threshold
418.81 ns
(-22.19%)Baseline: 538.23 ns
669.95 ns
(62.51%)
math/vec mat ops Lua📈 view plot
🚷 view threshold
6,371.60 ns
(-18.92%)Baseline: 7,858.28 ns
9,320.65 ns
(68.36%)
math/vec mat ops Rhai📈 view plot
🚷 view threshold
6,027.80 ns
(-19.49%)Baseline: 7,486.61 ns
8,686.41 ns
(69.39%)
query/10 entities Lua📈 view plot
🚷 view threshold
18,821.00 ns
(-25.12%)Baseline: 25,134.37 ns
30,696.23 ns
(61.31%)
query/10 entities Rhai📈 view plot
🚷 view threshold
18,625.00 ns
(-23.63%)Baseline: 24,387.77 ns
29,231.91 ns
(63.71%)
query/100 entities Lua📈 view plot
🚷 view threshold
39,493.00 ns
(-22.03%)Baseline: 50,651.90 ns
61,840.48 ns
(63.86%)
query/100 entities Rhai📈 view plot
🚷 view threshold
31,811.00 ns
(-19.67%)Baseline: 39,601.77 ns
48,396.75 ns
(65.73%)
query/1000 entities Lua📈 view plot
🚷 view threshold
274,380.00 ns
(-12.42%)Baseline: 313,307.00 ns
388,383.67 ns
(70.65%)
query/1000 entities Rhai📈 view plot
🚷 view threshold
176,750.00 ns
(-21.36%)Baseline: 224,772.00 ns
303,490.78 ns
(58.24%)
reflection/10 Lua📈 view plot
🚷 view threshold
5,362.00 ns
(-18.59%)Baseline: 6,586.47 ns
7,677.37 ns
(69.84%)
reflection/10 Rhai📈 view plot
🚷 view threshold
14,722.00 ns
(-10.61%)Baseline: 16,468.60 ns
18,157.15 ns
(81.08%)
reflection/100 Lua📈 view plot
🚷 view threshold
46,731.00 ns
(-12.59%)Baseline: 53,462.73 ns
60,673.04 ns
(77.02%)
reflection/100 Rhai📈 view plot
🚷 view threshold
704,910.00 ns
(-3.21%)Baseline: 728,255.33 ns
854,006.55 ns
(82.54%)
resource/access Lua📈 view plot
🚷 view threshold
3,005.80 ns
(-31.65%)Baseline: 4,397.48 ns
5,571.75 ns
(53.95%)
resource/access Rhai📈 view plot
🚷 view threshold
4,559.50 ns
(-24.85%)Baseline: 6,067.35 ns
7,595.68 ns
(60.03%)
resource/get Lua📈 view plot
🚷 view threshold
1,694.70 ns
(-30.80%)Baseline: 2,448.82 ns
3,024.64 ns
(56.03%)
resource/get Rhai📈 view plot
🚷 view threshold
3,290.00 ns
(-23.03%)Baseline: 4,274.39 ns
5,435.83 ns
(60.52%)
🐰 View full continuous benchmarking report in Bencher

@makspll makspll force-pushed the feat/response-callbacks branch from 50292e5 to 96b2a3d Compare April 1, 2025 18:57
@makspll makspll merged commit 87c6734 into main Apr 1, 2025
23 checks passed
@makspll makspll deleted the feat/response-callbacks branch April 1, 2025 19:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs documentation For features or changes which still need changes in the book
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant