seaweedfs/weed/messaging/broker/broker_grpc_server.go

38 lines
1.3 KiB
Go
Raw Normal View History

2020-04-18 16:12:01 +08:00
package broker
2020-04-16 17:55:09 +08:00
import (
"context"
2020-05-09 15:31:34 +08:00
"fmt"
2020-04-16 17:55:09 +08:00
2020-09-01 15:21:19 +08:00
"github.com/chrislusf/seaweedfs/weed/filer"
2020-05-09 15:31:34 +08:00
"github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
2020-04-16 17:55:09 +08:00
"github.com/chrislusf/seaweedfs/weed/pb/messaging_pb"
)
func (broker *MessageBroker) ConfigureTopic(c context.Context, request *messaging_pb.ConfigureTopicRequest) (*messaging_pb.ConfigureTopicResponse, error) {
panic("implement me")
}
2020-05-08 17:47:22 +08:00
func (broker *MessageBroker) DeleteTopic(c context.Context, request *messaging_pb.DeleteTopicRequest) (*messaging_pb.DeleteTopicResponse, error) {
2020-05-09 15:31:34 +08:00
resp := &messaging_pb.DeleteTopicResponse{}
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-10 02:21:23 +08:00
err = filer_pb.Remove(broker, dir, entry, true, true, true, false, nil)
2020-05-09 15:31:34 +08:00
}
return resp, nil
2020-05-08 17:47:22 +08:00
}
2020-04-16 17:55:09 +08:00
func (broker *MessageBroker) GetTopicConfiguration(c context.Context, request *messaging_pb.GetTopicConfigurationRequest) (*messaging_pb.GetTopicConfigurationResponse, error) {
panic("implement me")
}
2020-05-09 15:31:34 +08:00
func genTopicDir(namespace, topic string) string {
2020-09-01 15:21:19 +08:00
return fmt.Sprintf("%s/%s/%s", filer.TopicsDir, namespace, topic)
2020-05-09 15:31:34 +08:00
}
func genTopicDirEntry(namespace, topic string) (dir, entry string) {
2020-09-01 15:21:19 +08:00
return fmt.Sprintf("%s/%s", filer.TopicsDir, namespace), topic
2020-05-09 15:31:34 +08:00
}