macula_names (macula v0.20.5)

View Source

Shared naming utilities for hierarchical dot-separated names. Used by both pub/sub topics and RPC procedure names. Supports DNS-style reverse notation: org.domain.service.method

Summary

Functions

Get the local node ID. Returns the node ID stored in persistent_term, or generates one if not set. This is used for NAT detection to identify the local node.

Extract namespace (first segment).

Normalize name (lowercase, trim, remove double dots).

Count number of segments in name.

Validate name syntax with default options (no wildcards).

Validate name syntax with options. Valid names: - Non-empty - Segments separated by dots - Segments contain alphanumeric, underscore, hyphen - Optionally allow wildcards (* and #) for patterns - No leading or trailing dots - No double dots

Types

name/0

-type name() :: binary().

options/0

-type options() :: #{allow_wildcards => boolean()}.

Functions

local_node_id()

-spec local_node_id() -> binary().

Get the local node ID. Returns the node ID stored in persistent_term, or generates one if not set. This is used for NAT detection to identify the local node.

namespace(Name)

-spec namespace(name()) -> binary().

Extract namespace (first segment).

normalize(Name)

-spec normalize(name()) -> name().

Normalize name (lowercase, trim, remove double dots).

segment_count(Name)

-spec segment_count(name()) -> non_neg_integer().

Count number of segments in name.

validate(Name)

-spec validate(name()) -> ok | {error, invalid_name}.

Validate name syntax with default options (no wildcards).

validate(Name, Opts)

-spec validate(name(), options()) -> ok | {error, invalid_name}.

Validate name syntax with options. Valid names: - Non-empty - Segments separated by dots - Segments contain alphanumeric, underscore, hyphen - Optionally allow wildcards (* and #) for patterns - No leading or trailing dots - No double dots