Target string
}
-// Topic validates the address and returns its exact publication topic.
-func (a Address) Topic() (string, error) {
+// topic validates the address and returns its exact publication topic.
+func (a Address) topic() (string, error) {
if !ValidID(a.ID) {
return "", fmt.Errorf("address ID must be a canonical ULID")
}
return Root + "/devices/" + a.ID + "/" + string(a.Kind) + "/" + a.Target, nil
}
-// ParseTopic rejects malformed topics, wildcards, and unsupported operations.
-func ParseTopic(topic string) (Address, error) {
+// parseTopic rejects malformed topics, wildcards, and unsupported operations.
+func parseTopic(topic string) (Address, error) {
parts := strings.Split(topic, "/")
if len(parts) < 5 || parts[0]+"/"+parts[1] != Root {
return Address{}, fmt.Errorf("topic must use the versioned root")
return Address{}, fmt.Errorf("topic layout is invalid")
}
- canonical, err := address.Topic()
+ canonical, err := address.topic()
if err != nil {
return Address{}, fmt.Errorf("validate topic address: %w", err)
}