forked from TrueCloudLab/frostfs-node
[#1546] morph/event: Remove "is started" checks from event handler registrar
This codepath hides possible bugs in code. All initialization function should run before init stage. Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
This commit is contained in:
parent
670305a721
commit
dfa51048a8
2 changed files with 0 additions and 19 deletions
|
@ -164,11 +164,9 @@ const (
|
||||||
EventNotaryParserNotSet = "notary parser not set"
|
EventNotaryParserNotSet = "notary parser not set"
|
||||||
EventCouldNotParseNotaryEvent = "could not parse notary event"
|
EventCouldNotParseNotaryEvent = "could not parse notary event"
|
||||||
EventNotaryHandlersForParsedNotificationEventWereNotRegistered = "notary handlers for parsed notification event were not registered"
|
EventNotaryHandlersForParsedNotificationEventWereNotRegistered = "notary handlers for parsed notification event were not registered"
|
||||||
EventListenerHasBeenAlreadyStartedIgnoreParser = "listener has been already started, ignore parser"
|
|
||||||
EventRegisteredNewEventParser = "registered new event parser"
|
EventRegisteredNewEventParser = "registered new event parser"
|
||||||
EventIgnoreHandlerOfEventWoParser = "ignore handler of event w/o parser"
|
EventIgnoreHandlerOfEventWoParser = "ignore handler of event w/o parser"
|
||||||
EventRegisteredNewEventHandler = "registered new event handler"
|
EventRegisteredNewEventHandler = "registered new event handler"
|
||||||
EventListenerHasBeenAlreadyStartedIgnoreNotaryParser = "listener has been already started, ignore notary parser"
|
|
||||||
EventIgnoreHandlerOfNotaryEventWoParser = "ignore handler of notary event w/o parser"
|
EventIgnoreHandlerOfNotaryEventWoParser = "ignore handler of notary event w/o parser"
|
||||||
StorageOperation = "local object storage operation"
|
StorageOperation = "local object storage operation"
|
||||||
BlobovniczaCreatingDirectoryForBoltDB = "creating directory for BoltDB"
|
BlobovniczaCreatingDirectoryForBoltDB = "creating directory for BoltDB"
|
||||||
|
|
|
@ -100,8 +100,6 @@ type listener struct {
|
||||||
|
|
||||||
startOnce, stopOnce sync.Once
|
startOnce, stopOnce sync.Once
|
||||||
|
|
||||||
started bool
|
|
||||||
|
|
||||||
notificationParsers map[scriptHashWithType]NotificationParser
|
notificationParsers map[scriptHashWithType]NotificationParser
|
||||||
notificationHandlers map[scriptHashWithType][]Handler
|
notificationHandlers map[scriptHashWithType][]Handler
|
||||||
|
|
||||||
|
@ -171,9 +169,6 @@ func (l *listener) ListenWithError(ctx context.Context, intError chan<- error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *listener) listen(ctx context.Context, intError chan<- error) error {
|
func (l *listener) listen(ctx context.Context, intError chan<- error) error {
|
||||||
// mark listener as started
|
|
||||||
l.started = true
|
|
||||||
|
|
||||||
subErrCh := make(chan error)
|
subErrCh := make(chan error)
|
||||||
|
|
||||||
go l.subscribe(subErrCh)
|
go l.subscribe(subErrCh)
|
||||||
|
@ -462,12 +457,6 @@ func (l *listener) SetNotificationParser(pi NotificationParserInfo) {
|
||||||
l.mtx.Lock()
|
l.mtx.Lock()
|
||||||
defer l.mtx.Unlock()
|
defer l.mtx.Unlock()
|
||||||
|
|
||||||
// check if the listener was started
|
|
||||||
if l.started {
|
|
||||||
log.Warn(context.Background(), logs.EventListenerHasBeenAlreadyStartedIgnoreParser)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// add event parser
|
// add event parser
|
||||||
if _, ok := l.notificationParsers[pi.scriptHashWithType]; !ok {
|
if _, ok := l.notificationParsers[pi.scriptHashWithType]; !ok {
|
||||||
l.notificationParsers[pi.scriptHashWithType] = pi.parser()
|
l.notificationParsers[pi.scriptHashWithType] = pi.parser()
|
||||||
|
@ -546,12 +535,6 @@ func (l *listener) SetNotaryParser(pi NotaryParserInfo) {
|
||||||
l.mtx.Lock()
|
l.mtx.Lock()
|
||||||
defer l.mtx.Unlock()
|
defer l.mtx.Unlock()
|
||||||
|
|
||||||
// check if the listener was started
|
|
||||||
if l.started {
|
|
||||||
log.Warn(context.Background(), logs.EventListenerHasBeenAlreadyStartedIgnoreNotaryParser)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// add event parser
|
// add event parser
|
||||||
if _, ok := l.notaryParsers[pi.notaryRequestTypes]; !ok {
|
if _, ok := l.notaryParsers[pi.notaryRequestTypes]; !ok {
|
||||||
l.notaryParsers[pi.notaryRequestTypes] = pi.parser()
|
l.notaryParsers[pi.notaryRequestTypes] = pi.parser()
|
||||||
|
|
Loading…
Reference in a new issue