Last active
October 24, 2019 19:12
-
-
Save kyleparisi/a63d8982fbd4a6e700d902cdc02fc6a0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# {: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