Skip to content

Commit

Permalink
init once to struct member
Browse files Browse the repository at this point in the history
Signed-off-by: Amit Mor <[email protected]>
  • Loading branch information
amimimor committed Nov 1, 2023
1 parent 36e742a commit 44dc373
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions pubsub/aws/snssqs/subscription_mgmt.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ const (
Unsubscribe
)

var initOnce sync.Once

type SubscriptionTopicHandler struct {
topic string
requestTopic string
Expand All @@ -41,6 +39,7 @@ type SubscriptionManager struct {
topicsHandlers *xsync.MapOf[string, *SubscriptionTopicHandler]
lock sync.Mutex
wg sync.WaitGroup
initOnce sync.Once
}

type SubscriptionManagement interface {
Expand All @@ -67,7 +66,7 @@ func createQueueConsumerCbk(queueInfo *sqsQueueInfo, dlqInfo *sqsQueueInfo, cbk
}

func (sm *SubscriptionManager) Init(queueInfo *sqsQueueInfo, dlqInfo *sqsQueueInfo, cbk func(context.Context, *sqsQueueInfo, *sqsQueueInfo)) {
initOnce.Do(func() {
sm.initOnce.Do(func() {
queueConsumerCbk := createQueueConsumerCbk(queueInfo, dlqInfo, cbk)
go sm.queueConsumerController(queueConsumerCbk)
sm.logger.Debug("Subscription manager initialized")
Expand Down

0 comments on commit 44dc373

Please sign in to comment.