Pure helpers for formatting systemd unit names.
Systemd unit names are ordinary strings, but callers often need to format the
same patterns repeatedly: typed names such as dbus.service, template names
such as my_app@.service, and instance names such as my_app@4000.service.
This module keeps that formatting explicit without introducing a struct or a deployment-specific abstraction.
Examples
iex> Systemd.UnitName.new("dbus", :service)
"dbus.service"
iex> Systemd.UnitName.template("my_app", :service)
"my_app@.service"
iex> Systemd.UnitName.instance("my_app", 4000, :service)
"my_app@4000.service"
iex> Systemd.UnitName.ensure_type("my_app@4000", :service)
"my_app@4000.service"
iex> Systemd.UnitName.drop_type("my_app@4000.service")
"my_app@4000"
Summary
Functions
Drops the final systemd unit type suffix from a name.
Ensures a unit name has the suffix for type.
Formats a systemd instance unit name.
Formats a typed systemd unit name.
Formats a systemd template unit name.
Types
@type unit_type() :: :service | :socket | :timer | :target | :mount | :path | String.t()
Functions
Drops the final systemd unit type suffix from a name.
Ensures a unit name has the suffix for type.
@spec instance(String.t(), String.Chars.t(), unit_type()) :: String.t()
Formats a systemd instance unit name.
Formats a typed systemd unit name.
If name already ends with the requested type suffix, it is returned
unchanged.
Formats a systemd template unit name.