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
|
defmodule Livebook.Hubs.Fly do
|
||||||
@moduledoc false
|
@moduledoc false
|
||||||
|
|
||||||
use Ecto.Schema
|
use Ecto.Schema
|
||||||
import Ecto.Changeset
|
import Ecto.Changeset
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
defmodule Livebook.Hubs.Local do
|
defmodule Livebook.Hubs.Local do
|
||||||
@moduledoc false
|
@moduledoc false
|
||||||
|
|
||||||
defstruct [:id, :hub_name, :hub_color]
|
defstruct [:id, :hub_name, :hub_color]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
defmodule Livebook.Hubs.Metadata do
|
defmodule Livebook.Hubs.Metadata do
|
||||||
@moduledoc false
|
@moduledoc false
|
||||||
|
|
||||||
defstruct [:id, :name, :provider, :color]
|
defstruct [:id, :name, :provider, :color]
|
||||||
|
|
||||||
@type t :: %__MODULE__{
|
@type t :: %__MODULE__{
|
||||||
|
|
|
@ -502,6 +502,14 @@ defmodule Livebook.Session do
|
||||||
GenServer.cast(pid, {:set_file, self(), file})
|
GenServer.cast(pid, {:set_file, self(), file})
|
||||||
end
|
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 """
|
@doc """
|
||||||
Sends save request to the server.
|
Sends save request to the server.
|
||||||
|
|
||||||
|
@ -537,14 +545,6 @@ defmodule Livebook.Session do
|
||||||
:ok
|
:ok
|
||||||
end
|
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 """
|
@doc """
|
||||||
Disconnects one or more sessions from the current runtime.
|
Disconnects one or more sessions from the current runtime.
|
||||||
|
|
||||||
|
@ -970,13 +970,14 @@ defmodule Livebook.Session do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def handle_cast(:save, state) do
|
def handle_cast({:put_secret, client_pid, secret}, state) do
|
||||||
{:noreply, maybe_save_notebook_async(state)}
|
client_id = client_id(state, client_pid)
|
||||||
|
operation = {:put_secret, client_id, secret}
|
||||||
|
{:noreply, handle_operation(state, operation)}
|
||||||
end
|
end
|
||||||
|
|
||||||
def handle_cast({:put_secret, secret}, state) do
|
def handle_cast(:save, state) do
|
||||||
operation = {:put_secret, self(), secret}
|
{:noreply, maybe_save_notebook_async(state)}
|
||||||
{:noreply, handle_operation(state, operation)}
|
|
||||||
end
|
end
|
||||||
|
|
||||||
@impl true
|
@impl true
|
||||||
|
@ -1052,7 +1053,7 @@ defmodule Livebook.Session do
|
||||||
end
|
end
|
||||||
|
|
||||||
def handle_info({:user_change, user}, state) do
|
def handle_info({:user_change, user}, state) do
|
||||||
operation = {:update_user, self(), user}
|
operation = {:update_user, @client_id, user}
|
||||||
{:noreply, handle_operation(state, operation)}
|
{:noreply, handle_operation(state, operation)}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue