LemonGateway. Shared
(lemon_gateway v0.1.0)
View Source
Shared utility functions used across LemonGateway modules.
This module centralizes common helper functions to reduce duplication and provide consistent behavior for configuration access, data normalization, and type conversions across the codebase.
Summary
Functions
Safely broadcasts to LemonCore.Bus if available.
Canonicalizes a hostname by trimming, removing trailing dot, and lowercasing.
Safely emits telemetry events if LemonCore.Telemetry is available.
Fetches a value from a map or keyword list, trying both atom and string keys.
Fetches a nested value from a map by trying multiple key paths. Returns the first non-nil value found.
Fetches a value from a nested map structure following a path of keys.
Returns the first non-blank value from a list.
Returns the first non-nil value from a list.
Gets configuration for a transport from Config or Application env.
Converts a value to an integer with a default fallback.
Puts a value into a map only if the value is not nil.
Normalizes a bind IP configuration value to :loopback, :any, or parsed IP.
Normalizes a blank value (nil or empty/whitespace string) to nil.
Converts a map to a normalized map (handles keyword lists).
Parses an IP address string into a tuple.
Converts a value to a boolean with a default fallback.
Determines if a transport is enabled based on Config and Application env.
Checks if a value is truthy.
Functions
Safely broadcasts to LemonCore.Bus if available.
Canonicalizes a hostname by trimming, removing trailing dot, and lowercasing.
Safely emits telemetry events if LemonCore.Telemetry is available.
Fetches a value from a map or keyword list, trying both atom and string keys.
Fetches a nested value from a map by trying multiple key paths. Returns the first non-nil value found.
Fetches a value from a nested map structure following a path of keys.
Returns the first non-blank value from a list.
Returns the first non-nil value from a list.
Gets configuration for a transport from Config or Application env.
Converts a value to an integer with a default fallback.
Puts a value into a map only if the value is not nil.
@spec normalize_bind_ip(any()) :: :loopback | :any | :inet.ip_address()
Normalizes a bind IP configuration value to :loopback, :any, or parsed IP.
Normalizes a blank value (nil or empty/whitespace string) to nil.
Converts a map to a normalized map (handles keyword lists).
@spec parse_ip(String.t()) :: :inet.ip_address() | nil
Parses an IP address string into a tuple.
Converts a value to a boolean with a default fallback.
Determines if a transport is enabled based on Config and Application env.
Checks if a value is truthy.