-
Notifications
You must be signed in to change notification settings - Fork 0
/
messages.go
65 lines (54 loc) · 1.9 KB
/
messages.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
53
54
55
56
57
58
59
60
61
62
63
64
65
package orderingpb
import (
"github.com/ibiscum/Event-Driven-Architecture-in-Golang/Chapter09/internal/registry"
"github.com/ibiscum/Event-Driven-Architecture-in-Golang/Chapter09/internal/registry/serdes"
)
const (
OrderAggregateChannel = "mallbots.ordering.events.Order"
OrderCreatedEvent = "ordersapi.OrderCreated"
OrderRejectedEvent = "ordersapi.OrderRejected"
OrderApprovedEvent = "ordersapi.OrderApproved"
OrderReadiedEvent = "ordersapi.OrderReadied"
OrderCanceledEvent = "ordersapi.OrderCanceled"
OrderCompletedEvent = "ordersapi.OrderCompleted"
CommandChannel = "mallbots.ordering.commands"
RejectOrderCommand = "ordersapi.RejectOrder"
ApproveOrderCommand = "ordersapi.ApproveOrder"
)
func Registrations(reg registry.Registry) (err error) {
serde := serdes.NewProtoSerde(reg)
// Order events
if err = serde.Register(&OrderCreated{}); err != nil {
return err
}
if err = serde.Register(&OrderRejected{}); err != nil {
return err
}
if err = serde.Register(&OrderApproved{}); err != nil {
return err
}
if err = serde.Register(&OrderReadied{}); err != nil {
return err
}
if err = serde.Register(&OrderCanceled{}); err != nil {
return err
}
if err = serde.Register(&OrderCompleted{}); err != nil {
return err
}
if err = serde.Register(&RejectOrder{}); err != nil {
return err
}
if err = serde.Register(&ApproveOrder{}); err != nil {
return err
}
return nil
}
func (*OrderCreated) Key() string { return OrderCreatedEvent }
func (*OrderRejected) Key() string { return OrderRejectedEvent }
func (*OrderApproved) Key() string { return OrderApprovedEvent }
func (*OrderReadied) Key() string { return OrderReadiedEvent }
func (*OrderCanceled) Key() string { return OrderCanceledEvent }
func (*OrderCompleted) Key() string { return OrderCompletedEvent }
func (*RejectOrder) Key() string { return RejectOrderCommand }
func (*ApproveOrder) Key() string { return ApproveOrderCommand }