Skip to content

Instantly share code, notes, and snippets.

@kyleparisi
Last active October 24, 2019 19:12

Revisions

  1. kyleparisi revised this gist Oct 24, 2019. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions docker_events.ex
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,4 @@
    # {:httpoison, "~> 1.6"} in mix.exs -> deps
    defmodule DockerEvents do
    use GenServer

  2. kyleparisi revised this gist Oct 24, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion docker_events.ex
    Original file line number Diff line number Diff line change
    @@ -8,7 +8,7 @@ defmodule DockerEvents do
    def init(:ok) do
    sock = URI.encode_www_form("/var/run/docker.sock")
    url = "http+unix://#{sock}/events"
    {:ok, HTTPoison.get!(url, [], [stream_to: self])}
    {:ok, HTTPoison.get!(url, [], [stream_to: self, recv_timeout: :infinity])}
    end

    def handle_info(msg, state) do
  3. kyleparisi created this gist Oct 24, 2019.
    19 changes: 19 additions & 0 deletions docker_events.ex
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,19 @@
    defmodule DockerEvents do
    use GenServer

    def start_link(opts \\ []) do
    GenServer.start_link(__MODULE__, :ok, opts)
    end

    def init(:ok) do
    sock = URI.encode_www_form("/var/run/docker.sock")
    url = "http+unix://#{sock}/events"
    {:ok, HTTPoison.get!(url, [], [stream_to: self])}
    end

    def handle_info(msg, state) do
    IO.inspect {:handle_info, msg}
    {:noreply, state}
    end

    end