Skip to content

Commit

Permalink
more watcher guards
Browse files Browse the repository at this point in the history
  • Loading branch information
michaeljguarino committed Jan 13, 2023
1 parent 5c864ad commit f0d2f5f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
5 changes: 5 additions & 0 deletions lib/console/graphql/topic.ex
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
defprotocol Console.GraphQl.Topic do
@fallback_to_any true
@spec infer(struct, :create | :update | :delete) :: [{atom, binary}]
def infer(resource, delta)
end

defimpl Console.GraphQl.Topic, for: Any do
def infer(_, _), do: []
end

defimpl Console.GraphQl.Topic, for: Console.Schema.Build do
def infer(%{id: id}, _), do: [build_delta: "builds", build_delta: "builds:#{id}"]
end
Expand Down
7 changes: 4 additions & 3 deletions lib/console/watchers/pod.ex
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
defmodule Console.Watchers.Pod do
use Console.Watchers.Base
alias Kazan.Apis.Core.V1, as: CoreV1

def handle_info(:start, state) do
Logger.info "starting pod watcher"
request = Kazan.Apis.Core.V1.list_pod_for_all_namespaces!()
request = CoreV1.list_pod_for_all_namespaces!()
{:ok, pid} = Watcher.start_link(request, send_to: self(), recv_timeout: 15_000)

:timer.send_interval(5000, :watcher_ping)
Expand All @@ -16,8 +17,8 @@ defmodule Console.Watchers.Pod do
{:noreply, state}
end

def handle_info(%Watcher.Event{object: app, type: type}, state) do
publish(app, type)
def handle_info(%Watcher.Event{object: %CoreV1.Pod{} = pod, type: type}, state) do
publish(pod, type)
{:noreply, state}
end

Expand Down

0 comments on commit f0d2f5f

Please sign in to comment.