mirror of
https://github.com/livebook-dev/livebook.git
synced 2025-10-10 13:38:09 +08:00
Send client ids in session data operations
This commit is contained in:
parent
6469f0c380
commit
4cc18919da
4 changed files with 18 additions and 14 deletions
|
@ -1,5 +1,6 @@
|
|||
defmodule Livebook.Hubs.Fly do
|
||||
@moduledoc false
|
||||
|
||||
use Ecto.Schema
|
||||
import Ecto.Changeset
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
defmodule Livebook.Hubs.Local do
|
||||
@moduledoc false
|
||||
|
||||
defstruct [:id, :hub_name, :hub_color]
|
||||
end
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
defmodule Livebook.Hubs.Metadata do
|
||||
@moduledoc false
|
||||
|
||||
defstruct [:id, :name, :provider, :color]
|
||||
|
||||
@type t :: %__MODULE__{
|
||||
|
|
|
@ -502,6 +502,14 @@ defmodule Livebook.Session do
|
|||
GenServer.cast(pid, {:set_file, self(), file})
|
||||
end
|
||||
|
||||
@doc """
|
||||
Sends a secret addition request to the server.
|
||||
"""
|
||||
@spec put_secret(pid(), map()) :: :ok
|
||||
def put_secret(pid, secret) do
|
||||
GenServer.cast(pid, {:put_secret, self(), secret})
|
||||
end
|
||||
|
||||
@doc """
|
||||
Sends save request to the server.
|
||||
|
||||
|
@ -537,14 +545,6 @@ defmodule Livebook.Session do
|
|||
:ok
|
||||
end
|
||||
|
||||
@doc """
|
||||
Sends a secret addition request to the server.
|
||||
"""
|
||||
@spec put_secret(pid(), map()) :: :ok
|
||||
def put_secret(pid, secret) do
|
||||
GenServer.cast(pid, {:put_secret, secret})
|
||||
end
|
||||
|
||||
@doc """
|
||||
Disconnects one or more sessions from the current runtime.
|
||||
|
||||
|
@ -970,13 +970,14 @@ defmodule Livebook.Session do
|
|||
end
|
||||
end
|
||||
|
||||
def handle_cast(:save, state) do
|
||||
{:noreply, maybe_save_notebook_async(state)}
|
||||
def handle_cast({:put_secret, client_pid, secret}, state) do
|
||||
client_id = client_id(state, client_pid)
|
||||
operation = {:put_secret, client_id, secret}
|
||||
{:noreply, handle_operation(state, operation)}
|
||||
end
|
||||
|
||||
def handle_cast({:put_secret, secret}, state) do
|
||||
operation = {:put_secret, self(), secret}
|
||||
{:noreply, handle_operation(state, operation)}
|
||||
def handle_cast(:save, state) do
|
||||
{:noreply, maybe_save_notebook_async(state)}
|
||||
end
|
||||
|
||||
@impl true
|
||||
|
@ -1052,7 +1053,7 @@ defmodule Livebook.Session do
|
|||
end
|
||||
|
||||
def handle_info({:user_change, user}, state) do
|
||||
operation = {:update_user, self(), user}
|
||||
operation = {:update_user, @client_id, user}
|
||||
{:noreply, handle_operation(state, operation)}
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue