2023-08-21 05:53:05 +00:00
|
|
|
package topic
|
2022-07-10 08:36:23 +00:00
|
|
|
|
2022-07-11 07:20:27 +00:00
|
|
|
import (
|
2022-07-16 17:49:34 +00:00
|
|
|
"fmt"
|
2022-07-29 07:17:28 +00:00
|
|
|
"github.com/seaweedfs/seaweedfs/weed/pb/mq_pb"
|
2022-07-11 07:20:27 +00:00
|
|
|
)
|
2022-07-10 08:36:23 +00:00
|
|
|
|
|
|
|
type Topic struct {
|
2023-10-02 08:01:45 +00:00
|
|
|
Namespace string
|
2022-07-11 07:20:27 +00:00
|
|
|
Name string
|
2022-07-10 08:36:23 +00:00
|
|
|
}
|
|
|
|
|
2023-10-02 08:01:45 +00:00
|
|
|
func NewTopic(namespace string, name string) Topic {
|
2023-08-21 05:53:05 +00:00
|
|
|
return Topic{
|
|
|
|
Namespace: namespace,
|
|
|
|
Name: name,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
func FromPbTopic(topic *mq_pb.Topic) Topic {
|
|
|
|
return Topic{
|
2023-10-02 08:01:45 +00:00
|
|
|
Namespace: topic.Namespace,
|
2023-08-21 05:53:05 +00:00
|
|
|
Name: topic.Name,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-12-11 20:05:54 +00:00
|
|
|
func (tp Topic) ToPbTopic() *mq_pb.Topic {
|
|
|
|
return &mq_pb.Topic{
|
|
|
|
Namespace: tp.Namespace,
|
|
|
|
Name: tp.Name,
|
2022-07-11 07:20:27 +00:00
|
|
|
}
|
2022-07-10 08:36:23 +00:00
|
|
|
}
|
2022-07-16 17:49:34 +00:00
|
|
|
|
2023-12-11 20:05:54 +00:00
|
|
|
func (tp Topic) String() string {
|
|
|
|
return fmt.Sprintf("%s.%s", tp.Namespace, tp.Name)
|
2022-07-16 17:49:34 +00:00
|
|
|
}
|