concept action in category elixir

This is an excerpt from Manning's book The Little Elixir & OTP Guidebook.
Now that you’ve seen the worker in action, let’s take a closer look at how it works, beginning with the temperature_of/1 function:
Listing 8.11. Handling input arguments using OptionParser (lib/cli.ex)
use Mix.Config defmodule Blitzy.CLI do require Logger def main(args) do args |> parse_args |> process_options end defp parse_args(args) do OptionParser.parse(args, aliases: [n: :requests], strict: [requests: :integer]) end defp process_options(options, nodes) do case options do {[requests: n], [url], []} -> # perform action _ -> do_help end end end
Failover happens when a node running an application goes down, and that application is restarted on another node automatically, given some timeout period. Takeover happens when a node has a higher priority (defined in a list) than the currently running node, causing the lower-priority node to stop and the application to be restarted on the higher-priority node. Failovers and takeovers are cool (in programming, at least) because it seems like black magic when you see them in action. Once you know the mechanics, they will seem pretty straightforward, but no less cool.