Fold scripting runtime into Lua
This commit is contained in:
@@ -6,7 +6,7 @@ defmodule BDS.Scripting do
|
||||
require Logger
|
||||
|
||||
alias BDS.Scripting.Capabilities
|
||||
alias BDS.Scripting.Runtime
|
||||
alias BDS.Scripting.Lua
|
||||
|
||||
@type job_status :: :queued | :running | :completed | :failed | :cancelled
|
||||
@type job_snapshot :: %{
|
||||
@@ -31,7 +31,7 @@ defmodule BDS.Scripting do
|
||||
runtime().validate(source)
|
||||
end
|
||||
|
||||
@spec execute(String.t(), String.t(), [term()], [Runtime.execution_option()]) ::
|
||||
@spec execute(String.t(), String.t(), [term()], [Lua.execution_option()]) ::
|
||||
{:ok, term()} | {:error, term()}
|
||||
def execute(source, entrypoint, args \\ [], opts \\ [])
|
||||
when is_binary(source) and is_binary(entrypoint) and is_list(args) and is_list(opts) do
|
||||
@@ -39,7 +39,7 @@ defmodule BDS.Scripting do
|
||||
end
|
||||
|
||||
@spec execute_project_script(String.t(), String.t(), String.t(), [term()], [
|
||||
Runtime.execution_option()
|
||||
Lua.execution_option()
|
||||
]) ::
|
||||
{:ok, term()} | {:error, term()}
|
||||
def execute_project_script(project_id, source, entrypoint, args \\ [], opts \\ [])
|
||||
@@ -75,7 +75,7 @@ defmodule BDS.Scripting do
|
||||
end
|
||||
end
|
||||
|
||||
@spec start_job(String.t(), String.t(), [term()], [Runtime.execution_option()]) ::
|
||||
@spec start_job(String.t(), String.t(), [term()], [Lua.execution_option()]) ::
|
||||
{:ok, job_snapshot()} | {:error, term()}
|
||||
def start_job(source, entrypoint, args \\ [], opts \\ [])
|
||||
when is_binary(source) and is_binary(entrypoint) and is_list(args) and is_list(opts) do
|
||||
|
||||
@@ -6,7 +6,23 @@ defmodule BDS.Scripting.Lua do
|
||||
and opt-in.
|
||||
"""
|
||||
|
||||
@behaviour BDS.Scripting.Runtime
|
||||
@type source :: String.t()
|
||||
@type entrypoint :: String.t()
|
||||
@type args :: [term()]
|
||||
@type progress_event :: map()
|
||||
@type progress_callback :: (progress_event() -> any())
|
||||
@type execution_option ::
|
||||
{:timeout, non_neg_integer() | :infinity}
|
||||
| {:max_reductions, pos_integer() | :none}
|
||||
| {:spawn_opts, [term()]}
|
||||
| {:on_progress, progress_callback()}
|
||||
| {:capabilities, map()}
|
||||
|
||||
@callback validate(source()) :: :ok | {:error, term()}
|
||||
@callback execute(source(), entrypoint(), args(), [execution_option()]) ::
|
||||
{:ok, term()} | {:error, term()}
|
||||
|
||||
@behaviour __MODULE__
|
||||
|
||||
@type lua_state :: tuple()
|
||||
@type runtime_result :: {:ok, term(), lua_state} | {:error, term()}
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
defmodule BDS.Scripting.Runtime do
|
||||
@moduledoc """
|
||||
Behaviour for user-script runtimes hosted by bDS.
|
||||
|
||||
The runtime boundary is intentionally narrow: syntax validation and
|
||||
bounded entrypoint execution.
|
||||
"""
|
||||
|
||||
@type source :: String.t()
|
||||
@type entrypoint :: String.t()
|
||||
@type args :: [term()]
|
||||
@type progress_event :: map()
|
||||
@type progress_callback :: (progress_event() -> any())
|
||||
@type execution_option ::
|
||||
{:timeout, non_neg_integer() | :infinity}
|
||||
| {:max_reductions, pos_integer() | :none}
|
||||
| {:spawn_opts, [term()]}
|
||||
| {:on_progress, progress_callback()}
|
||||
| {:capabilities, map()}
|
||||
|
||||
@callback validate(source()) :: :ok | {:error, term()}
|
||||
@callback execute(source(), entrypoint(), args(), [execution_option()]) ::
|
||||
{:ok, term()} | {:error, term()}
|
||||
end
|
||||
Reference in New Issue
Block a user