mirror of
https://github.com/livebook-dev/livebook.git
synced 2024-12-29 11:11:19 +08:00
79e5c432b3
* Isolate evaluation in separate node for each session * Start new remote upon first evaluation and handle nodedown * Add UI for managing evaluation node, improve naming and structure * Show runtime initialization errors and some fixes * Improve standalone node initialization * Correctly handle multiple sessions connecting to the same node * Fix session tests concerning evaluation * Documentation and some refactoring * Various improvements * Configure schedulers to get to sleep immediately after evaluation * Move EvaluatorSpervisor into the Remote namespace * Fix evaluators cleanup * Add tests * Improve flash messages * Introduce remote genserver taking care of cleanup * Redefine the Runtime protocol to serve as an interface for evaluation * Cleanup operations * Use reference for communication with a standalone node * Use shortnames for distribution by default * Update node configuration and make sure epmd is running * Rename Remote to ErlDist
45 lines
1.1 KiB
Elixir
45 lines
1.1 KiB
Elixir
defmodule LiveBookTest.Runtime.SingleEvaluator do
|
|
@moduledoc false
|
|
|
|
# A simple runtime backed by a single evaluator process
|
|
# running on the local node.
|
|
#
|
|
# This allows for working code evaluation without
|
|
# starting a standalone Elixir runtime, so is neat for testing.
|
|
|
|
defstruct [:evaluator]
|
|
|
|
def init() do
|
|
with {:ok, evaluator} <- LiveBook.Evaluator.start_link() do
|
|
{:ok, %__MODULE__{evaluator: evaluator}}
|
|
end
|
|
end
|
|
end
|
|
|
|
defimpl LiveBook.Runtime, for: LiveBookTest.Runtime.SingleEvaluator do
|
|
alias LiveBook.Evaluator
|
|
|
|
def connect(runtime) do
|
|
Process.monitor(runtime.evaluator)
|
|
end
|
|
|
|
def disconnect(_runtime), do: :ok
|
|
|
|
def evaluate_code(
|
|
runtime,
|
|
code,
|
|
_container_ref,
|
|
evaluation_ref,
|
|
prev_evaluation_ref \\ :initial
|
|
) do
|
|
Evaluator.evaluate_code(runtime.evaluator, self(), code, evaluation_ref, prev_evaluation_ref)
|
|
|
|
:ok
|
|
end
|
|
|
|
def forget_evaluation(runtime, _container_ref, evaluation_ref) do
|
|
Evaluator.forget_evaluation(runtime.evaluator, evaluation_ref)
|
|
end
|
|
|
|
def drop_container(_runtime, _container_ref), do: :ok
|
|
end
|