mirror of
https://github.com/minio/minio.git
synced 2025-11-20 01:50:24 -05:00
Make addition of TopicConfig to globalEventNotifier go-routine safe (#2806)
This commit is contained in:
committed by
Harshavardhana
parent
f72163f856
commit
5fdd768903
@@ -137,17 +137,6 @@ func (en *eventNotifier) RemoveSNSTarget(snsARN string, listenerCh chan []Notifi
|
||||
}
|
||||
}
|
||||
|
||||
// Returns true if bucket notification is set for the bucket, false otherwise.
|
||||
func (en *eventNotifier) IsBucketNotificationSet(bucket string) bool {
|
||||
if en == nil {
|
||||
return false
|
||||
}
|
||||
en.rwMutex.RLock()
|
||||
defer en.rwMutex.RUnlock()
|
||||
_, ok := en.notificationConfigs[bucket]
|
||||
return ok
|
||||
}
|
||||
|
||||
// Fetch bucket notification config for an input bucket.
|
||||
func (en eventNotifier) GetBucketNotificationConfig(bucket string) *notificationConfig {
|
||||
en.rwMutex.RLock()
|
||||
@@ -167,6 +156,23 @@ func (en *eventNotifier) SetBucketNotificationConfig(bucket string, notification
|
||||
return nil
|
||||
}
|
||||
|
||||
func (en *eventNotifier) AddTopicConfig(bucket string, topicCfg *topicConfig) error {
|
||||
en.rwMutex.Lock()
|
||||
defer en.rwMutex.Unlock()
|
||||
if topicCfg == nil {
|
||||
return errInvalidArgument
|
||||
}
|
||||
notificationCfg := en.notificationConfigs[bucket]
|
||||
if notificationCfg == nil {
|
||||
en.notificationConfigs[bucket] = ¬ificationConfig{
|
||||
TopicConfigs: []topicConfig{*topicCfg},
|
||||
}
|
||||
return nil
|
||||
}
|
||||
notificationCfg.TopicConfigs = append(notificationCfg.TopicConfigs, *topicCfg)
|
||||
return nil
|
||||
}
|
||||
|
||||
// eventNotify notifies an event to relevant targets based on their
|
||||
// bucket notification configs.
|
||||
func eventNotify(event eventData) {
|
||||
|
||||
Reference in New Issue
Block a user