broker_grpc_server.go 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. package broker
  2. import (
  3. "context"
  4. "fmt"
  5. "github.com/chrislusf/seaweedfs/weed/filer2"
  6. "github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
  7. "github.com/chrislusf/seaweedfs/weed/pb/messaging_pb"
  8. )
  9. func (broker *MessageBroker) ConfigureTopic(c context.Context, request *messaging_pb.ConfigureTopicRequest) (*messaging_pb.ConfigureTopicResponse, error) {
  10. panic("implement me")
  11. }
  12. func (broker *MessageBroker) DeleteTopic(c context.Context, request *messaging_pb.DeleteTopicRequest) (*messaging_pb.DeleteTopicResponse, error) {
  13. resp := &messaging_pb.DeleteTopicResponse{}
  14. dir, entry := genTopicDirEntry(request.Namespace, request.Topic)
  15. if exists, err := filer_pb.Exists(broker, dir, entry, true); err != nil {
  16. return nil, err
  17. } else if exists {
  18. err = filer_pb.Remove(broker, dir, entry, true, true, true, false)
  19. }
  20. return resp, nil
  21. }
  22. func (broker *MessageBroker) GetTopicConfiguration(c context.Context, request *messaging_pb.GetTopicConfigurationRequest) (*messaging_pb.GetTopicConfigurationResponse, error) {
  23. panic("implement me")
  24. }
  25. func genTopicDir(namespace, topic string) string {
  26. return fmt.Sprintf("%s/%s/%s", filer2.TopicsDir, namespace, topic)
  27. }
  28. func genTopicDirEntry(namespace, topic string) (dir, entry string) {
  29. return fmt.Sprintf("%s/%s", filer2.TopicsDir, namespace), topic
  30. }