Skip to content

Commit

Permalink
fixes #304, uses new shape of heartbeat (#314)
Browse files Browse the repository at this point in the history
Signed-off-by: Brooks Townsend <[email protected]>
  • Loading branch information
brooksmtownsend authored Dec 7, 2021
1 parent 5fd2b00 commit f6f93a2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
21 changes: 11 additions & 10 deletions wasmcloud_host/lib/wasmcloud_host/lattice/state_monitor.ex
Original file line number Diff line number Diff line change
Expand Up @@ -257,17 +257,18 @@ defmodule WasmcloudHost.Lattice.StateMonitor do
actor_map =
actors
|> Enum.reduce(%{}, fn actor, actor_map ->
actor_id = Map.get(actor, "actor")
existing_actor = current_host |> Map.get(:actors, %{}) |> Map.get(actor_id)
actor_id = Map.get(actor, "public_key")

if existing_actor != nil && Map.get(existing_actor, :count) == Map.get(actor, "instances") do
Map.put(actor_map, actor_id, existing_actor)
else
Map.put(actor_map, actor_id, %{
count: Map.get(actor, "instances"),
status: "Awaiting"
})
end
actor_info = Map.get(actor_map, actor_id, %{})
count = Map.get(actor_info, :count, 0) + 1

status =
current_host
|> Map.get(:actors, %{})
|> Map.get(actor_id, %{})
|> Map.get(:status, "Awaiting")

Map.put(actor_map, actor_id, %{count: count, status: status})
end)

# TODO: Also ensure that providers don't exist in the dashboard that aren't in the health check
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
<tbody>
<%= for {host_id, host_map} <- display_hosts do %>
<%= for {actor, info_map} <- Map.get(host_map, :actors, %{}) do %>
<% actor_name = @claims |> Enum.find(fn {k, _v} -> k == actor end) |> elem(1) |> Map.get(:name) %>
<% actor_name = @claims |> Enum.find({"", %{}}, fn {k, _v} -> k == actor end) |> elem(1) |> Map.get(:name, "N/A") %>
<% oci_ref = @ocirefs |> Enum.find({"", actor}, fn {_oci, id} -> id == actor end) |> elem(0) %>
<% count = Map.get(info_map, :count) %>
<% status = Map.get(info_map, :status) %>
Expand Down Expand Up @@ -257,6 +257,7 @@
<%= Map.get(@hosts, host_id, %{})
|> Map.get(:actors, %{})
|> Enum.map(fn {_actor_id, info} -> Map.get(info, :count, 0) end)
|> Enum.filter(fn count -> count != nil end)
|> Enum.reduce(0, fn count, acc -> count + acc end) %>
</td>
<td>
Expand Down

0 comments on commit f6f93a2

Please sign in to comment.