mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
44 lines
981 B
Go
44 lines
981 B
Go
package notification
|
|
|
|
import (
|
|
"github.com/chrislusf/seaweedfs/weed/glog"
|
|
"github.com/spf13/viper"
|
|
"github.com/chrislusf/seaweedfs/weed/util"
|
|
"github.com/golang/protobuf/proto"
|
|
)
|
|
|
|
type MessageQueue interface {
|
|
// GetName gets the name to locate the configuration in filer.toml file
|
|
GetName() string
|
|
// Initialize initializes the file store
|
|
Initialize(configuration util.Configuration) error
|
|
SendMessage(key string, message proto.Message) error
|
|
}
|
|
|
|
var (
|
|
MessageQueues []MessageQueue
|
|
|
|
Queue MessageQueue
|
|
)
|
|
|
|
func LoadConfiguration(config *viper.Viper) {
|
|
|
|
if config == nil {
|
|
return
|
|
}
|
|
|
|
for _, store := range MessageQueues {
|
|
if config.GetBool(store.GetName() + ".enabled") {
|
|
viperSub := config.Sub(store.GetName())
|
|
if err := store.Initialize(viperSub); err != nil {
|
|
glog.Fatalf("Failed to initialize store for %s: %+v",
|
|
store.GetName(), err)
|
|
}
|
|
Queue = store
|
|
glog.V(0).Infof("Configure message queue for %s", store.GetName())
|
|
return
|
|
}
|
|
}
|
|
|
|
}
|