mirror of
https://github.com/minio/minio.git
synced 2025-11-25 20:16:10 -05:00
config: setter/getter for Notifier and Logger into its own struct. (#3721)
This is an attempt cleanup code and keep the top level config functions simpler and easy to understand where as move the notifier related code and logger setter/getter methods as part of their own struct. Locks are now held properly not globally by configMutex, but instead as private variables. Final fix for #3700
This commit is contained in:
@@ -54,24 +54,12 @@ const (
|
||||
|
||||
var errNotifyNotEnabled = errors.New("requested notifier not enabled")
|
||||
|
||||
// Notifier represents collection of supported notification queues.
|
||||
type notifier struct {
|
||||
AMQP map[string]amqpNotify `json:"amqp"`
|
||||
NATS map[string]natsNotify `json:"nats"`
|
||||
ElasticSearch map[string]elasticSearchNotify `json:"elasticsearch"`
|
||||
Redis map[string]redisNotify `json:"redis"`
|
||||
PostgreSQL map[string]postgreSQLNotify `json:"postgresql"`
|
||||
Kafka map[string]kafkaNotify `json:"kafka"`
|
||||
Webhook map[string]webhookNotify `json:"webhook"`
|
||||
// Add new notification queues.
|
||||
}
|
||||
|
||||
// Returns true if queueArn is for an AMQP queue.
|
||||
func isAMQPQueue(sqsArn arnSQS) bool {
|
||||
if sqsArn.Type != queueTypeAMQP {
|
||||
return false
|
||||
}
|
||||
amqpL := serverConfig.GetAMQPNotifyByID(sqsArn.AccountID)
|
||||
amqpL := serverConfig.Notify.GetAMQPByID(sqsArn.AccountID)
|
||||
if !amqpL.Enable {
|
||||
return false
|
||||
}
|
||||
@@ -90,7 +78,7 @@ func isNATSQueue(sqsArn arnSQS) bool {
|
||||
if sqsArn.Type != queueTypeNATS {
|
||||
return false
|
||||
}
|
||||
natsL := serverConfig.GetNATSNotifyByID(sqsArn.AccountID)
|
||||
natsL := serverConfig.Notify.GetNATSByID(sqsArn.AccountID)
|
||||
if !natsL.Enable {
|
||||
return false
|
||||
}
|
||||
@@ -109,7 +97,7 @@ func isWebhookQueue(sqsArn arnSQS) bool {
|
||||
if sqsArn.Type != queueTypeWebhook {
|
||||
return false
|
||||
}
|
||||
rNotify := serverConfig.GetWebhookNotifyByID(sqsArn.AccountID)
|
||||
rNotify := serverConfig.Notify.GetWebhookByID(sqsArn.AccountID)
|
||||
if !rNotify.Enable {
|
||||
return false
|
||||
}
|
||||
@@ -121,7 +109,7 @@ func isRedisQueue(sqsArn arnSQS) bool {
|
||||
if sqsArn.Type != queueTypeRedis {
|
||||
return false
|
||||
}
|
||||
rNotify := serverConfig.GetRedisNotifyByID(sqsArn.AccountID)
|
||||
rNotify := serverConfig.Notify.GetRedisByID(sqsArn.AccountID)
|
||||
if !rNotify.Enable {
|
||||
return false
|
||||
}
|
||||
@@ -140,7 +128,7 @@ func isElasticQueue(sqsArn arnSQS) bool {
|
||||
if sqsArn.Type != queueTypeElastic {
|
||||
return false
|
||||
}
|
||||
esNotify := serverConfig.GetElasticSearchNotifyByID(sqsArn.AccountID)
|
||||
esNotify := serverConfig.Notify.GetElasticSearchByID(sqsArn.AccountID)
|
||||
if !esNotify.Enable {
|
||||
return false
|
||||
}
|
||||
@@ -158,7 +146,7 @@ func isPostgreSQLQueue(sqsArn arnSQS) bool {
|
||||
if sqsArn.Type != queueTypePostgreSQL {
|
||||
return false
|
||||
}
|
||||
pgNotify := serverConfig.GetPostgreSQLNotifyByID(sqsArn.AccountID)
|
||||
pgNotify := serverConfig.Notify.GetPostgreSQLByID(sqsArn.AccountID)
|
||||
if !pgNotify.Enable {
|
||||
return false
|
||||
}
|
||||
@@ -176,7 +164,7 @@ func isKafkaQueue(sqsArn arnSQS) bool {
|
||||
if sqsArn.Type != queueTypeKafka {
|
||||
return false
|
||||
}
|
||||
kafkaNotifyCfg := serverConfig.GetKafkaNotifyByID(sqsArn.AccountID)
|
||||
kafkaNotifyCfg := serverConfig.Notify.GetKafkaByID(sqsArn.AccountID)
|
||||
if !kafkaNotifyCfg.Enable {
|
||||
return false
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user