forked from looplab/eventhorizon
-
Notifications
You must be signed in to change notification settings - Fork 0
/
commands.go
84 lines (68 loc) · 2.98 KB
/
commands.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
// Copyright (c) 2014 - Max Ekman <max@looplab.se>
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package domain
import (
eh "github.com/looplab/eventhorizon"
)
func init() {
eh.RegisterCommand(func() eh.Command { return &CreateInvite{} })
eh.RegisterCommand(func() eh.Command { return &AcceptInvite{} })
eh.RegisterCommand(func() eh.Command { return &DeclineInvite{} })
eh.RegisterCommand(func() eh.Command { return &ConfirmInvite{} })
eh.RegisterCommand(func() eh.Command { return &DenyInvite{} })
}
const (
CreateInviteCommand eh.CommandType = "CreateInvite"
AcceptInviteCommand eh.CommandType = "AcceptInvite"
DeclineInviteCommand eh.CommandType = "DeclineInvite"
ConfirmInviteCommand eh.CommandType = "ConfirmInvite"
DenyInviteCommand eh.CommandType = "DenyInvite"
)
// CreateInvite is a command for creating invites.
type CreateInvite struct {
ID eh.UUID
Name string
Age int `eh:"optional"`
}
func (c CreateInvite) AggregateID() eh.UUID { return c.ID }
func (c CreateInvite) AggregateType() eh.AggregateType { return InvitationAggregateType }
func (c CreateInvite) CommandType() eh.CommandType { return CreateInviteCommand }
// AcceptInvite is a command for accepting invites.
type AcceptInvite struct {
ID eh.UUID
}
func (c AcceptInvite) AggregateID() eh.UUID { return c.ID }
func (c AcceptInvite) AggregateType() eh.AggregateType { return InvitationAggregateType }
func (c AcceptInvite) CommandType() eh.CommandType { return AcceptInviteCommand }
// DeclineInvite is a command for declining invites.
type DeclineInvite struct {
ID eh.UUID
}
func (c DeclineInvite) AggregateID() eh.UUID { return c.ID }
func (c DeclineInvite) AggregateType() eh.AggregateType { return InvitationAggregateType }
func (c DeclineInvite) CommandType() eh.CommandType { return DeclineInviteCommand }
// ConfirmInvite is a command for confirming invites.
type ConfirmInvite struct {
ID eh.UUID
}
func (c ConfirmInvite) AggregateID() eh.UUID { return c.ID }
func (c ConfirmInvite) AggregateType() eh.AggregateType { return InvitationAggregateType }
func (c ConfirmInvite) CommandType() eh.CommandType { return ConfirmInviteCommand }
// DenyInvite is a command for confirming invites.
type DenyInvite struct {
ID eh.UUID
}
func (c DenyInvite) AggregateID() eh.UUID { return c.ID }
func (c DenyInvite) AggregateType() eh.AggregateType { return InvitationAggregateType }
func (c DenyInvite) CommandType() eh.CommandType { return DenyInviteCommand }