X-Git-Url: https://git.giacomolli.uk/onehouse/blobdiff_plain/b28ae53ae04c41116acb2beae9d5a2128a187c83..4bba0e163f1a4dc07b34fd9e4dc403de1f9b4cb9:/protocol/address.go?ds=sidebyside diff --git a/protocol/address.go b/protocol/address.go index fbd0d26..7786dfd 100644 --- a/protocol/address.go +++ b/protocol/address.go @@ -48,8 +48,8 @@ type Address struct { 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") } @@ -88,8 +88,8 @@ func (a Address) Topic() (string, error) { 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") @@ -119,7 +119,7 @@ func ParseTopic(topic string) (Address, error) { 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) }