mix malachi.policy (malachi v0.22.7)

View Source

Administer storage policies on a running Malachi node from the box, over Erlang distribution (RPC): define and delete named policies, bind a topic to one, and read back what a topic's retention actually is. A policy lives in the cluster's replicated policy store and a binding in the topic's own metadata, so a change made through any node applies cluster-wide.

mix malachi.policy list
mix malachi.policy define <name> [--set <field>=<value>]... [--off <field>]...
mix malachi.policy delete <name> [--force]
mix malachi.policy bind <topic> <name>
mix malachi.policy unbind <topic>
mix malachi.policy get <topic>

A field left out of define inherits the cluster's global value; --off turns that rule off for the policy's topics; 0 is a real budget (--set retention.max_bytes=0 expires every sealed segment). The fields are retention.max_age_ms, retention.max_bytes (non-negative integers), retention.segment_max_age_ms (how old an active segment may get before it is rolled, at least 60000) and spread_by (a broker attribute key). retention.segment_max_age_ms needs control-plane machine version 6.

delete refuses a policy a topic is still bound to, because such a topic stops expiring anything once the name no longer resolves; --force deletes it anyway. bind refuses a name the store does not define. get prints each bound's effective value and where it comes from (policy, global, or unresolved_backstop for a topic bound to a name nothing defines).

Binding needs control-plane machine version 4: during a rolling upgrade it is refused until every node runs a release that implements it and the version pin is lifted.

Options:

  • --node: the target node (default $MALACHI_NODE or malachi@127.0.0.1)
  • --cookie: the Erlang cookie (default $RELEASE_COOKIE, else ~/.erlang.cookie)

The target node must be named (a release, or iex --name ... -S mix).

Summary

Functions

The testable core: maps a parsed command to a Malachi.Policies call through call (a (module, fun, args -> {:ok, value} | {:error, reason}) seam that in production is an RPC to the target node). Field values are parsed here, against this build's field table, so a typo is refused before anything is sent. Returns {:ok, message} / {:error, message} for the caller to print.

Functions

execute(arg1, opts, call)

@spec execute([String.t()], keyword(), (module(), atom(), list() ->
                                    {:ok, term()} | {:error, term()})) ::
  {:ok, String.t()} | {:error, String.t()}

The testable core: maps a parsed command to a Malachi.Policies call through call (a (module, fun, args -> {:ok, value} | {:error, reason}) seam that in production is an RPC to the target node). Field values are parsed here, against this build's field table, so a typo is refused before anything is sent. Returns {:ok, message} / {:error, message} for the caller to print.