]> git.giacomolli.uk - onehouse/blobdiff - protocol/address.go
Share the Alamo gateway request budget
[onehouse] / protocol / address.go
index fbd0d2686c0bc2d5684f95c1024073cf4b09a0a1..7786dfdfdb3d6c7f3f6bb38ddc255ff70b70d18f 100644 (file)
@@ -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)
        }