-
Notifications
You must be signed in to change notification settings - Fork 2
/
topics.go
33 lines (25 loc) · 865 Bytes
/
topics.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package connector
import (
"fmt"
"strings"
)
type TopicName string
type TopicPersistency string
const (
//topic persistency prefix
TopicTypePersistent TopicPersistency = "persistent"
TopicTypeNonPersistent TopicPersistency = "non-persistent"
)
func BuildTopic(persistency TopicPersistency, tenant, namespace string, topicName TopicName) string {
return fmt.Sprintf("%s://%s/%s/%s", persistency, tenant, namespace, topicName)
}
func BuildPersistentTopic(tenant, namespace string, topicName TopicName) string {
return BuildTopic(TopicTypePersistent, tenant, namespace, topicName)
}
func BuildNonPersistentTopic(tenant, namespace string, topicName TopicName) string {
return BuildTopic(TopicTypeNonPersistent, tenant, namespace, topicName)
}
func GetTopicName(topic string) string {
parts := strings.Split(topic, "/")
return parts[len(parts)-1]
}