Created
December 12, 2019 19:14
-
-
Save x-ji/5bb76e3959a8c557a97c5fc2d59e5489 to your computer and use it in GitHub Desktop.
Markdium-Elixir process orchestration in Kubernetes with libcluster and swarm
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 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