2021-06-09 22:24:02 +08:00
|
|
|
defmodule Livebook.Runtime.NoopRuntime do
|
|
|
|
@moduledoc false
|
|
|
|
|
|
|
|
# A runtime that doesn't do any actual evaluation,
|
|
|
|
# thus not requiring any underlying resources.
|
|
|
|
|
|
|
|
defstruct []
|
|
|
|
|
|
|
|
def new(), do: %__MODULE__{}
|
|
|
|
|
|
|
|
defimpl Livebook.Runtime do
|
2022-02-10 02:47:26 +08:00
|
|
|
def connect(_, _), do: make_ref()
|
2021-06-09 22:24:02 +08:00
|
|
|
def disconnect(_), do: :ok
|
2021-07-16 00:19:36 +08:00
|
|
|
def evaluate_code(_, _, _, _, _ \\ []), do: :ok
|
|
|
|
def forget_evaluation(_, _), do: :ok
|
2021-06-09 22:24:02 +08:00
|
|
|
def drop_container(_, _), do: :ok
|
2021-07-21 03:30:53 +08:00
|
|
|
def handle_intellisense(_, _, _, _, _), do: :ok
|
2021-07-01 19:23:07 +08:00
|
|
|
def duplicate(_), do: {:ok, Livebook.Runtime.NoopRuntime.new()}
|
2021-12-24 21:18:34 +08:00
|
|
|
def standalone?(_), do: false
|
|
|
|
|
|
|
|
def read_file(_, path) do
|
|
|
|
case File.read(path) do
|
|
|
|
{:ok, content} -> {:ok, content}
|
|
|
|
{:error, posix} -> {:error, posix |> :file.format_error() |> List.to_string()}
|
|
|
|
end
|
|
|
|
end
|
2022-02-28 20:53:33 +08:00
|
|
|
|
|
|
|
def start_smart_cell(_, _, _, _), do: :ok
|
|
|
|
|
|
|
|
def stop_smart_cell(_, _), do: :ok
|
2021-06-09 22:24:02 +08:00
|
|
|
end
|
|
|
|
end
|