make event manager just do initial only once

pull/385/head
Michael Li 1 year ago
parent 65dc7d0738
commit da4f2f1810
No known key found for this signature in database

@ -5,13 +5,18 @@
package events
import (
"sync"
"github.com/alimy/tryst/event"
"github.com/alimy/tryst/pool"
"github.com/rocboss/paopao-ce/internal/conf"
"github.com/sirupsen/logrus"
)
var _defaultEventManager event.EventManager
var (
_defaultEventManager event.EventManager
_onceInitial sync.Once
)
// OnEvent push event to gorotine pool then handled automatic.
func OnEvent(event event.Event) {
@ -19,6 +24,7 @@ func OnEvent(event event.Event) {
}
func Initial() {
_onceInitial.Do(func() {
var opts []pool.Option
s := conf.EventManagerSetting
if s.MinWorker > 5 {
@ -40,6 +46,7 @@ func Initial() {
_defaultEventManager = event.NewEventManager(func(req event.Event, err error) {
logrus.Errorf("handle event[%s] occurs error: %s", req.Name(), err)
}, opts...)
})
}
func Restart() {

Loading…
Cancel
Save