Some work has been done on making the Connection feel nicer, but also more work is needed to not have the channel be exposed to the upper layers of the application. We should wrap all the GRPC calls in the GenServer (which may also allow caching on certain calls such as get_sys_info)
26 lines
718 B
Elixir
26 lines
718 B
Elixir
defmodule Prymn.Servers.Server do
|
|
use Ecto.Schema
|
|
import Ecto.Changeset
|
|
|
|
schema "servers" do
|
|
field :name, :string
|
|
field :public_ip, :string
|
|
field :provider, Ecto.Enum, values: [:Hetzner, :Custom]
|
|
field :registration_token, :binary, redact: true
|
|
|
|
field :status, Ecto.Enum,
|
|
values: [:unregistered, :registered],
|
|
default: :unregistered
|
|
|
|
timestamps()
|
|
end
|
|
|
|
@doc false
|
|
def changeset(server, attrs) do
|
|
server
|
|
|> cast(attrs, [:name, :public_ip, :provider, :registration_token, :status])
|
|
|> validate_required([:name, :provider])
|
|
|> validate_inclusion(:provider, [:Custom], message: "Provider not available (yet)")
|
|
|> unique_constraint([:public_ip])
|
|
end
|
|
end
|