forked from TrueCloudLab/frostfs-node
[#1546] morph/event: Merge notification parser and handlers
They are decoupled, but it is an error to have a handler without a corresponding parser. Register them together on the code level and get rid of unreachable code. Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
This commit is contained in:
parent
dfa51048a8
commit
d0ce835fbf
13 changed files with 44 additions and 191 deletions
|
@ -18,17 +18,23 @@ type BlockHandler func(context.Context, *block.Block)
|
|||
type NotificationHandlerInfo struct {
|
||||
scriptHashWithType
|
||||
|
||||
h Handler
|
||||
parser NotificationParser
|
||||
handlers []Handler
|
||||
}
|
||||
|
||||
// SetHandler is an event handler setter.
|
||||
func (s *NotificationHandlerInfo) SetHandler(v Handler) {
|
||||
s.h = v
|
||||
// SetParser is an event handler setter.
|
||||
func (s *NotificationHandlerInfo) SetParser(p NotificationParser) {
|
||||
s.parser = p
|
||||
}
|
||||
|
||||
// AddHandler adds an event handler.
|
||||
func (s *NotificationHandlerInfo) AddHandler(v Handler) {
|
||||
s.handlers = append(s.handlers, v)
|
||||
}
|
||||
|
||||
// Handler returns an event handler.
|
||||
func (s NotificationHandlerInfo) Handler() Handler {
|
||||
return s.h
|
||||
func (s NotificationHandlerInfo) Handlers() []Handler {
|
||||
return s.handlers
|
||||
}
|
||||
|
||||
// NotaryHandlerInfo is a structure that groups
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue