Created
December 12, 2019 19:39
-
-
Save x-ji/9af15de67414d9cfbf32ef252ce90506 to your computer and use it in GitHub Desktop.
Markdium-Elixir process orchestration in Kubernetes with libcluster and swarm
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
defmodule Yourapp.YourWorker do | |
use GenServer | |
def start_link(state) do | |
GenServer.start_link(__MODULE__, state) | |
end | |
def init(opts) do | |
initial_state = initialize_worker(opts) | |
{:ok, initial_state} | |
end | |
def handle_call({:swarm, :begin_handoff}, _from, state) do | |
{:reply, :restart, state} | |
end | |
def handle_info({:swarm, :die}, state) do | |
{:stop, :shutdown, state} | |
end | |
defp initialize_worker(opts) do | |
# ... | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment