You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

43 lines
981 B

6 years ago
6 years ago
6 years ago
  1. package notification
  2. import (
  3. "github.com/chrislusf/seaweedfs/weed/glog"
  4. "github.com/chrislusf/seaweedfs/weed/util"
  5. "github.com/golang/protobuf/proto"
  6. "github.com/spf13/viper"
  7. )
  8. type MessageQueue interface {
  9. // GetName gets the name to locate the configuration in filer.toml file
  10. GetName() string
  11. // Initialize initializes the file store
  12. Initialize(configuration util.Configuration) error
  13. SendMessage(key string, message proto.Message) error
  14. }
  15. var (
  16. MessageQueues []MessageQueue
  17. Queue MessageQueue
  18. )
  19. func LoadConfiguration(config *viper.Viper) {
  20. if config == nil {
  21. return
  22. }
  23. for _, store := range MessageQueues {
  24. if config.GetBool(store.GetName() + ".enabled") {
  25. viperSub := config.Sub(store.GetName())
  26. if err := store.Initialize(viperSub); err != nil {
  27. glog.Fatalf("Failed to initialize store for %s: %+v",
  28. store.GetName(), err)
  29. }
  30. Queue = store
  31. glog.V(0).Infof("Configure message queue for %s", store.GetName())
  32. return
  33. }
  34. }
  35. }