summaryrefslogtreecommitdiff
path: root/events/init.go
blob: 25e92fc5427c88ccbaec2d7b9ce4e3ad92b03b19 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
package events

import (
	"sync"

	"github.com/google/uuid"
)

var evBus *eventsBus
var onInit = &sync.Once{}

func Bus() (*eventsBus, string) {
	onInit.Do(func() {
		evBus = newEventsBus()
		go evBus.handleEvents()
	})

	// return events bus with subscriberID
	return evBus, uuid.NewString()
}