2020-04-18 08:12:01 +00:00
|
|
|
package broker
|
2020-04-16 09:55:09 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2020-05-09 07:31:34 +00:00
|
|
|
"fmt"
|
2020-04-16 09:55:09 +00:00
|
|
|
|
2020-09-01 07:21:19 +00:00
|
|
|
"github.com/chrislusf/seaweedfs/weed/filer"
|
2020-05-09 07:31:34 +00:00
|
|
|
"github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
|
2022-07-02 05:43:25 +00:00
|
|
|
"github.com/chrislusf/seaweedfs/weed/pb/mq_pb"
|
2020-04-16 09:55:09 +00:00
|
|
|
)
|
|
|
|
|
2022-07-02 06:34:51 +00:00
|
|
|
func (broker *MessageQueueBroker) ConfigureTopic(c context.Context, request *mq_pb.ConfigureTopicRequest) (*mq_pb.ConfigureTopicResponse, error) {
|
2020-04-16 09:55:09 +00:00
|
|
|
panic("implement me")
|
|
|
|
}
|
|
|
|
|
2022-07-02 06:34:51 +00:00
|
|
|
func (broker *MessageQueueBroker) DeleteTopic(c context.Context, request *mq_pb.DeleteTopicRequest) (*mq_pb.DeleteTopicResponse, error) {
|
2022-07-02 05:43:25 +00:00
|
|
|
resp := &mq_pb.DeleteTopicResponse{}
|
2020-05-09 07:31:34 +00:00
|
|
|
dir, entry := genTopicDirEntry(request.Namespace, request.Topic)
|
|
|
|
if exists, err := filer_pb.Exists(broker, dir, entry, true); err != nil {
|
|
|
|
return nil, err
|
|
|
|
} else if exists {
|
2020-09-09 18:21:23 +00:00
|
|
|
err = filer_pb.Remove(broker, dir, entry, true, true, true, false, nil)
|
2020-05-09 07:31:34 +00:00
|
|
|
}
|
|
|
|
return resp, nil
|
2020-05-08 09:47:22 +00:00
|
|
|
}
|
|
|
|
|
2022-07-02 06:34:51 +00:00
|
|
|
func (broker *MessageQueueBroker) GetTopicConfiguration(c context.Context, request *mq_pb.GetTopicConfigurationRequest) (*mq_pb.GetTopicConfigurationResponse, error) {
|
2020-04-16 09:55:09 +00:00
|
|
|
panic("implement me")
|
|
|
|
}
|
2020-05-09 07:31:34 +00:00
|
|
|
|
|
|
|
func genTopicDir(namespace, topic string) string {
|
2020-09-01 07:21:19 +00:00
|
|
|
return fmt.Sprintf("%s/%s/%s", filer.TopicsDir, namespace, topic)
|
2020-05-09 07:31:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func genTopicDirEntry(namespace, topic string) (dir, entry string) {
|
2020-09-01 07:21:19 +00:00
|
|
|
return fmt.Sprintf("%s/%s", filer.TopicsDir, namespace), topic
|
2020-05-09 07:31:34 +00:00
|
|
|
}
|