Skip to content

Instantly share code, notes, and snippets.

@adkron
Created September 22, 2017 16:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adkron/2b585ce4118e11cb22231df8a87ebc14 to your computer and use it in GitHub Desktop.
Save adkron/2b585ce4118e11cb22231df8a87ebc14 to your computer and use it in GitHub Desktop.
defmodule DeviceHandler.Sync.Device do
alias DeviceHandler.Sync.Device.{Server}
alias DeviceHandler.Sync.{HubRegistry}
def new(interval, serial, options \\ []) do
options = Keyword.put_new(options, :name, HubRegistry.name(serial))
GenServer.start_link(Server, [interval, serial], options)
end
def child_spec([]) do
%{
id: __MODULE__,
start: {__MODULE__, :new, [100]},
restart: :permanent,
shutdown: 5000,
type: :worker
}
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment