Skip to content

Instantly share code, notes, and snippets.

@kyleparisi
Last active October 24, 2019 19:12
Show Gist options
  • Save kyleparisi/a63d8982fbd4a6e700d902cdc02fc6a0 to your computer and use it in GitHub Desktop.
Save kyleparisi/a63d8982fbd4a6e700d902cdc02fc6a0 to your computer and use it in GitHub Desktop.
# {: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