topic.go 586 B

1234567891011121314151617181920212223242526272829303132333435
  1. package topic
  2. import (
  3. "fmt"
  4. "github.com/seaweedfs/seaweedfs/weed/pb/mq_pb"
  5. )
  6. type Topic struct {
  7. Namespace string
  8. Name string
  9. }
  10. func NewTopic(namespace string, name string) Topic {
  11. return Topic{
  12. Namespace: namespace,
  13. Name: name,
  14. }
  15. }
  16. func FromPbTopic(topic *mq_pb.Topic) Topic {
  17. return Topic{
  18. Namespace: topic.Namespace,
  19. Name: topic.Name,
  20. }
  21. }
  22. func (tp Topic) ToPbTopic() *mq_pb.Topic {
  23. return &mq_pb.Topic{
  24. Namespace: tp.Namespace,
  25. Name: tp.Name,
  26. }
  27. }
  28. func (tp Topic) String() string {
  29. return fmt.Sprintf("%s.%s", tp.Namespace, tp.Name)
  30. }