Update server list dynamically
This commit is contained in:
parent
8b9c344577
commit
86d3808e54
|
@ -12,6 +12,7 @@ defmodule Chronoscope.NTS do
|
|||
@registry Application.compile_env(:chronoscope, :registry, Registry)
|
||||
@genserver Application.compile_env(:chronoscope, :gen_server, GenServer)
|
||||
@dynamic_supervisor Application.compile_env(:chronoscope, :dynamic_supervisor, DynamicSupervisor)
|
||||
@topic "nts-servers"
|
||||
|
||||
def healthy?() do
|
||||
true
|
||||
|
@ -37,6 +38,7 @@ defmodule Chronoscope.NTS do
|
|||
%{host: host, port: port}
|
||||
|> client_pid()
|
||||
|> @genserver.call(:key_establishment)
|
||||
|> tap(fn _ -> ChronoscopeWeb.Endpoint.broadcast(@topic, "", "") end)
|
||||
end
|
||||
|
||||
defp client_pid(server) do
|
||||
|
|
|
@ -10,7 +10,7 @@ defmodule ChronoscopeWeb.IndexLive do
|
|||
{:ok, assign(socket, %{servers: NTS.list()})}
|
||||
end
|
||||
|
||||
def handle_info(%{topic: @topic, payload: servers}, socket) do
|
||||
{:noreply, assign(socket, %{servers: servers})}
|
||||
def handle_info(%{topic: @topic}, socket) do
|
||||
{:noreply, assign(socket, %{servers: NTS.list()})}
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,21 +1,27 @@
|
|||
<table class="mx-auto border-collapse table-auto min-w-full divide-y divide-zinc-200 dark:divide-zinc-700 text-left">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col" class="py-3 px-6">
|
||||
<th scope="col" class="py-3 px-6 whitespace-nowrap">
|
||||
Host
|
||||
</th>
|
||||
<th scope="col" class="py-3 px-6">
|
||||
<th scope="col" class="py-3 px-6 whitespace-nowrap">
|
||||
Status
|
||||
</th>
|
||||
<th scope="col" class="py-3 px-6">
|
||||
<th scope="col" class="py-3 px-6 whitespace-nowrap">
|
||||
Algorithm
|
||||
</th>
|
||||
<th scope="col" class="py-3 px-6">
|
||||
<th scope="col" class="py-3 px-6 whitespace-nowrap">
|
||||
Cookies
|
||||
</th>
|
||||
<th scope="col" class="py-3 px-6">
|
||||
<th scope="col" class="py-3 px-6 whitespace-nowrap">
|
||||
Cookie Length
|
||||
</th>
|
||||
<th scope="col" class="py-3 px-6 whitespace-nowrap">
|
||||
Certificate Expiration
|
||||
</th>
|
||||
<th scope="col" class="py-3 px-6 whitespace-nowrap">
|
||||
Last Check
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
@ -38,6 +44,12 @@
|
|||
<td class="py-4 px-6 whitespace-nowrap">
|
||||
<%= response.cookie_length %>
|
||||
</td>
|
||||
<td class="py-4 px-6 whitespace-nowrap">
|
||||
<%= response.cert_expiration %>
|
||||
</td>
|
||||
<td class="py-4 px-6 whitespace-nowrap">
|
||||
<%= server.last_key_establishment %>
|
||||
</td>
|
||||
|
||||
<% else %>
|
||||
<td class="py-4 px-6 whitespace-nowrap">
|
||||
|
@ -54,6 +66,11 @@
|
|||
<td class="py-4 px-6 whitespace-nowrap"> - </td>
|
||||
<td class="py-4 px-6 whitespace-nowrap"> - </td>
|
||||
<td class="py-4 px-6 whitespace-nowrap"> - </td>
|
||||
<td class="py-4 px-6 whitespace-nowrap"> - </td>
|
||||
|
||||
<td class="py-4 px-6 whitespace-nowrap">
|
||||
<%= server.last_key_establishment %>
|
||||
</td>
|
||||
<% end %>
|
||||
</tr>
|
||||
</tbody>
|
||||
|
|
|
@ -8,7 +8,6 @@ defmodule Chronoscope.GeminiTest do
|
|||
|
||||
import Mox
|
||||
|
||||
setup :verify_on_exit!
|
||||
|
||||
describe "Chronoscope.Gemini.healthy?()" do
|
||||
test "is healthy" do
|
||||
|
|
|
@ -1,8 +1,17 @@
|
|||
defmodule ChronoscopeWeb.PageControllerTest do
|
||||
use ChronoscopeWeb.ConnCase, async: true
|
||||
|
||||
alias Chronoscope.DynamicSupervisorMock
|
||||
|
||||
import Mox
|
||||
|
||||
setup :verify_on_exit!
|
||||
|
||||
test "GET /", %{conn: conn} do
|
||||
DynamicSupervisorMock
|
||||
|> expect(:which_children, fn _ -> [] end)
|
||||
|
||||
conn = get(conn, ~p"/")
|
||||
assert html_response(conn, 200) =~ "Peace of mind from prototype to production"
|
||||
assert html_response(conn, 200) =~ "Chronoscope"
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue