Documentation ¶
Index ¶
- func NewBookRoomHandler() cqrs.CommanfHandlerFactory
- func NewBookingsFinancialReport() cqrs.EventHandlerFactory
- func NewOrderBeerHandler() cqrs.CommanfHandlerFactory
- func NewOrderBeerOnRoomBooked() cqrs.EventHandlerFactory
- type BeerOrdered
- type BookRoom
- type BookRoomHandler
- type BookingsFinancialReport
- type OrderBeer
- type OrderBeerHandler
- type OrderBeerOnRoomBooked
- type RoomBooked
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewBookRoomHandler ¶
func NewBookRoomHandler() cqrs.CommanfHandlerFactory
NewBookRoomHandler implements cqrs.CommanfHandlerFactory interface.
func NewBookingsFinancialReport ¶
func NewBookingsFinancialReport() cqrs.EventHandlerFactory
NewBookingsFinancialReport implements cqrs.EventHandlerFactory interface.
func NewOrderBeerHandler ¶
func NewOrderBeerHandler() cqrs.CommanfHandlerFactory
NewOrderBeerHandler implements cqrs.CommanfHandlerFactory interface.
func NewOrderBeerOnRoomBooked ¶
func NewOrderBeerOnRoomBooked() cqrs.EventHandlerFactory
NewOrderBeerOnRoomBooked implements cqrs.EventHandlerFactory interface.
Types ¶
type BeerOrdered ¶
type BookRoomHandler ¶
type BookRoomHandler struct {
// contains filtered or unexported fields
}
BookRoomHandler is a command handler, which handles BookRoom command and emits RoomBooked.
In CQRS, one command must be handled by only one handler. When another handler with this command is added to command processor, error will be retuerned.
func (BookRoomHandler) Handle ¶
func (b BookRoomHandler) Handle(ctx context.Context, c interface{}) error
func (BookRoomHandler) HandlerName ¶
func (b BookRoomHandler) HandlerName() string
func (BookRoomHandler) NewCommand ¶
func (b BookRoomHandler) NewCommand() interface{}
NewCommand returns type of command which this handle should handle. It must be a pointer.
type BookingsFinancialReport ¶
type BookingsFinancialReport struct {
// contains filtered or unexported fields
}
BookingsFinancialReport is a read model, which calculates how much money we may earn from bookings. Like OrderBeerOnRoomBooked, it listens for RoomBooked event.
This implementation is just writing to the memory. In production, you will probably will use some persistent storage.
func (*BookingsFinancialReport) Handle ¶
func (b *BookingsFinancialReport) Handle(ctx context.Context, e interface{}) error
func (*BookingsFinancialReport) HandlerName ¶
func (b *BookingsFinancialReport) HandlerName() string
func (*BookingsFinancialReport) NewEvent ¶
func (b *BookingsFinancialReport) NewEvent() interface{}
type OrderBeerHandler ¶
type OrderBeerHandler struct {
// contains filtered or unexported fields
}
OrderBeerHandler is a command handler, which handles OrderBeer command and emits BeerOrdered. BeerOrdered is not handled by any event handler, but we may use persistent Pub/Sub to handle it in the future.
func (OrderBeerHandler) Handle ¶
func (o OrderBeerHandler) Handle(ctx context.Context, c interface{}) error
func (OrderBeerHandler) HandlerName ¶
func (o OrderBeerHandler) HandlerName() string
func (OrderBeerHandler) NewCommand ¶
func (o OrderBeerHandler) NewCommand() interface{}
type OrderBeerOnRoomBooked ¶
type OrderBeerOnRoomBooked struct {
// contains filtered or unexported fields
}
OrderBeerOnRoomBooked is a event handler, which handles RoomBooked event and emits OrderBeer command.
func (OrderBeerOnRoomBooked) Handle ¶
func (o OrderBeerOnRoomBooked) Handle(ctx context.Context, e interface{}) error
func (OrderBeerOnRoomBooked) HandlerName ¶
func (o OrderBeerOnRoomBooked) HandlerName() string
func (OrderBeerOnRoomBooked) NewEvent ¶
func (OrderBeerOnRoomBooked) NewEvent() interface{}
type RoomBooked ¶
type RoomBooked struct { ReservationId string `json:"reservation_id,omitempty"` RoomId string `json:"room_id,omitempty"` GuestName string `json:"guest_name,omitempty"` Price int64 `json:"price,omitempty"` StartDate *time.Time `json:"start_date,omitempty"` EndDate *time.Time `json:"end_date,omitempty"` UnixTime int64 `json:"unix_time,omitempty"` }