-
Notifications
You must be signed in to change notification settings - Fork 175
/
zz_generated.event_handler.go
52 lines (42 loc) · 1.47 KB
/
zz_generated.event_handler.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// +build !ignore_autogenerated
// Code generated by mga tool. DO NOT EDIT.
package todogen
import (
"context"
"emperror.dev/errors"
"fmt"
"github.com/sagikazarmark/modern-go-application/internal/app/mga/todo"
)
// MarkedAsCompleteHandler handles MarkedAsComplete events.
type MarkedAsCompleteHandler interface {
// MarkedAsComplete handles a(n) MarkedAsComplete event.
MarkedAsComplete(ctx context.Context, event todo.MarkedAsComplete) error
}
// MarkedAsCompleteEventHandler handles MarkedAsComplete events.
type MarkedAsCompleteEventHandler struct {
handler MarkedAsCompleteHandler
name string
}
// NewMarkedAsCompleteEventHandler returns a new MarkedAsCompleteEventHandler instance.
func NewMarkedAsCompleteEventHandler(handler MarkedAsCompleteHandler, name string) MarkedAsCompleteEventHandler {
return MarkedAsCompleteEventHandler{
handler: handler,
name: name,
}
}
// HandlerName returns the name of the event handler.
func (h MarkedAsCompleteEventHandler) HandlerName() string {
return h.name
}
// NewEvent returns a new empty event used for serialization.
func (h MarkedAsCompleteEventHandler) NewEvent() interface{} {
return &todo.MarkedAsComplete{}
}
// Handle handles an event.
func (h MarkedAsCompleteEventHandler) Handle(ctx context.Context, event interface{}) error {
e, ok := event.(*todo.MarkedAsComplete)
if !ok {
return errors.NewWithDetails("unexpected event type", "type", fmt.Sprintf("%T", event))
}
return h.handler.MarkedAsComplete(ctx, *e)
}