Created
September 21, 2016 18:40
-
-
Save rawman/5d6e231cce45b80f7b0c78550d12c5f8 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| defmodule IntegrationMonitor.FooBar do | |
| def start_link do | |
| import Supervisor.Spec | |
| children = [supervisor(IntegrationMonitor.Foo, [], restart: :transient)] | |
| Supervisor.start_link(children, strategy: :simple_one_for_one, max_restarts: 3, max_seconds: 20, name: __MODULE__) | |
| end | |
| def start_child do | |
| Supervisor.start_child(__MODULE__, []) | |
| end | |
| end | |
| defmodule IntegrationMonitor.Foo do | |
| use GenServer | |
| @work_interval :timer.seconds(1) | |
| def start_link do | |
| GenServer.start_link(__MODULE__, nil, name: __MODULE__) | |
| end | |
| def init(_) do | |
| IO.puts "initializing foo" | |
| :timer.send_interval(@work_interval, :work) | |
| {:ok, nil} | |
| end | |
| def handle_info(:work, integration) do | |
| raise "ala mo kota" | |
| {:noreply, integration} | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment