Skip to content

Instantly share code, notes, and snippets.

@x-ji
Created December 12, 2019 19:39
Show Gist options
  • Save x-ji/9af15de67414d9cfbf32ef252ce90506 to your computer and use it in GitHub Desktop.
Save x-ji/9af15de67414d9cfbf32ef252ce90506 to your computer and use it in GitHub Desktop.
Markdium-Elixir process orchestration in Kubernetes with libcluster and swarm
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