Skip to content

Instantly share code, notes, and snippets.

@kyleparisi
Last active October 24, 2019 19:12
Embed
What would you like to do?
# {:httpoison, "~> 1.6"} in mix.exs -> deps
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, recv_timeout: :infinity])}
end
def handle_info(msg, state) do
IO.inspect {:handle_info, msg}
{:noreply, state}
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment