You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the current design, the crashd programmatic API relies completely on built-in functions defined in the project. However, as a user of the crashd API, it would be nice to be able to inject custom Starlark functions that are defined using Go.
Design
When using Crashd as a programmatic API, a developer should be able to define custom built-in Starlark functions and be able to use that function in scripts. For instance, suppose I want to define a custom function, called repeat, that prints a value N times, as shown:
repeat(value="Hello", count=2)
The previous function is not part of the core Crashd functions, however, the Crashd API should provide a way to inject a Go definition, for that function, so that it can be invoked in Crashd scripts.
Next, the Crashd API should provide a way to register the function prior to launching. For instance, the snippet below shows how someone, using the crashd API, would programmatically launch crashd and inject custom function to be made available to executing scripts:
In the current design, the crashd programmatic API relies completely on built-in functions defined in the project. However, as a user of the crashd API, it would be nice to be able to inject custom Starlark functions that are defined using Go.
Design
When using Crashd as a programmatic API, a developer should be able to define custom built-in Starlark functions and be able to use that function in scripts. For instance, suppose I want to define a custom function, called
repeat
, that prints a value N times, as shown:The previous function is not part of the core Crashd functions, however, the Crashd API should provide a way to inject a Go definition, for that function, so that it can be invoked in Crashd scripts.
Define custom function in Go
Register custom func with Crashd
Next, the Crashd API should provide a way to register the function prior to launching. For instance, the snippet below shows how someone, using the crashd API, would programmatically launch crashd and inject custom function to be made available to executing scripts:
Where
NewWithBuiltins
is defined asfunc NewWithBuiltins(scriptfile string, StarlarkBuiltin...)
StarlarkBuiltin
is defined asThe text was updated successfully, but these errors were encountered: