Skip to content

New rhai function: checkpoint(..) #8

@rubbieKelvin

Description

@rubbieKelvin

i want to add a new function for our rhai engine. checkpoint(when: bool, message: str, observe: map<str, value>) basically what this does is when the funtion is called, we want to block execution when the condition is true, so that the user can take time to observe the logs before the execution continues.

Issue:

the problem is, we currently have two interfaces for this:

  • cli
  • web.

On the cli we can ask the user to "press enter to continue", waiting for keyboard input to resume script execution.
But for the web, we might need to be a little creative.

Brainstorming a little

checkpoint needs a synchronous wait inside Rhai (same thread that runs the script) plus a second signal (CLI: stdin; web: HTTP) that unblocks it. seems like this maps cleanly to a wait handle injected when we build the engine; eg. Arc or a closure, implemented differently for CLI vs web.

cLI is straightforward: if when is true, log message + dump observe, then block on stdin (“Press Enter…”).

the web is harder because one HTTP request currently is the whole script run: the client doesn’t get a response until spawn_blocking returns, so it never learns “i'm at a checkpoint” from that same response in time to call “continue” unless we add another channel for events.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions