macula_pubsub_topic (macula v0.20.5)
View SourceTopic utilities for pub/sub system. Handles topic validation, pattern matching, and normalization. Supports MQTT-style wildcards: * (single-level) and # (multi-level).
Summary
Functions
Check if topic matches pattern. Patterns can contain: - * matches exactly one segment - # matches zero or more segments
Extract namespace (first segment).
Normalize topic (lowercase, trim, remove double dots).
Count number of segments in topic.
Validate topic syntax. Valid topics: - Non-empty - Segments separated by dots - Segments contain alphanumeric, underscore, hyphen, wildcards - No leading or trailing dots
Types
Functions
Check if topic matches pattern. Patterns can contain: - * matches exactly one segment - # matches zero or more segments
Extract namespace (first segment).
Normalize topic (lowercase, trim, remove double dots).
-spec segment_count(topic()) -> non_neg_integer().
Count number of segments in topic.
-spec validate(topic()) -> ok | {error, invalid_topic}.
Validate topic syntax. Valid topics: - Non-empty - Segments separated by dots - Segments contain alphanumeric, underscore, hyphen, wildcards - No leading or trailing dots