Skip to content

SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.

refactoring

Chris Luc28e8a239729
diff --git a/weed/command/filer_replication.go b/weed/command/filer_replication.go
index 087a12059b..3384e40232 100644
--- a/weed/command/filer_replication.go
+++ b/weed/command/filer_replication.go
@@ -41,16 +41,7 @@ func runFilerReplicate(cmd *Command, args []string) bool {
var notificationInput sub.NotificationInput
- enabledInput := ""
- for _, input := range sub.NotificationInputs {
- if config.GetBool("notification." + input.GetName() + ".enabled") {
- if enabledInput == "" {
- enabledInput = input.GetName()
- } else {
- glog.Fatalf("Notification input is enabled for both %s and %s", enabledInput, input.GetName())
- }
- }
- }
+ validateOneEnabledInput(config)
for _, input := range sub.NotificationInputs {
if config.GetBool("notification." + input.GetName() + ".enabled") {
@@ -133,3 +124,16 @@ func runFilerReplicate(cmd *Command, args []string) bool {
return true
}
+
+func validateOneEnabledInput(config *viper.Viper) {
+ enabledInput := ""
+ for _, input := range sub.NotificationInputs {
+ if config.GetBool("notification." + input.GetName() + ".enabled") {
+ if enabledInput == "" {
+ enabledInput = input.GetName()
+ } else {
+ glog.Fatalf("Notification input is enabled for both %s and %s", enabledInput, input.GetName())
+ }
+ }
+ }
+}
diff --git a/weed/filer2/configuration.go b/weed/filer2/configuration.go
index 4b20b608b6..7b05b53dc7 100644
--- a/weed/filer2/configuration.go
+++ b/weed/filer2/configuration.go
@@ -13,16 +13,7 @@ var (
func (f *Filer) LoadConfiguration(config *viper.Viper) {
- enabledStore := ""
- for _, store := range Stores {
- if config.GetBool(store.GetName() + ".enabled") {
- if enabledStore == "" {
- enabledStore = store.GetName()
- } else {
- glog.Fatalf("Filer store is enabled for both %s and %s", enabledStore, store.GetName())
- }
- }
- }
+ validateOneEnabledStore(config)
for _, store := range Stores {
if config.GetBool(store.GetName() + ".enabled") {
@@ -45,3 +36,16 @@ func (f *Filer) LoadConfiguration(config *viper.Viper) {
os.Exit(-1)
}
+
+func validateOneEnabledStore(config *viper.Viper) {
+ enabledStore := ""
+ for _, store := range Stores {
+ if config.GetBool(store.GetName() + ".enabled") {
+ if enabledStore == "" {
+ enabledStore = store.GetName()
+ } else {
+ glog.Fatalf("Filer store is enabled for both %s and %s", enabledStore, store.GetName())
+ }
+ }
+ }
+}
diff --git a/weed/notification/configuration.go b/weed/notification/configuration.go
index f34ccf3056..7f8765cc3d 100644
--- a/weed/notification/configuration.go
+++ b/weed/notification/configuration.go
@@ -27,16 +27,7 @@ func LoadConfiguration(config *viper.Viper) {
return
}
- enabledQueue := ""
- for _, queue := range MessageQueues {
- if config.GetBool(queue.GetName() + ".enabled") {
- if enabledQueue == "" {
- enabledQueue = queue.GetName()
- } else {
- glog.Fatalf("Notification message queue is enabled for both %s and %s", enabledQueue, queue.GetName())
- }
- }
- }
+ validateOneEnabledQueue(config)
for _, queue := range MessageQueues {
if config.GetBool(queue.GetName() + ".enabled") {
@@ -52,3 +43,16 @@ func LoadConfiguration(config *viper.Viper) {
}
}
+
+func validateOneEnabledQueue(config *viper.Viper) {
+ enabledQueue := ""
+ for _, queue := range MessageQueues {
+ if config.GetBool(queue.GetName() + ".enabled") {
+ if enabledQueue == "" {
+ enabledQueue = queue.GetName()
+ } else {
+ glog.Fatalf("Notification message queue is enabled for both %s and %s", enabledQueue, queue.GetName())
+ }
+ }
+ }
+}