Rename event name
This commit is contained in:
parent
8de81194bd
commit
a2396a093b
|
@ -801,8 +801,8 @@ func (Dev) MakeEvent(name, module string) error {
|
||||||
type ` + name + ` struct {
|
type ` + name + ` struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// TopicName defines the name for ` + name + `
|
// Name defines the name for ` + name + `
|
||||||
func (t *` + name + `) TopicName() string {
|
func (t *` + name + `) Name() string {
|
||||||
return "` + eventName + `"
|
return "` + eventName + `"
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
@ -861,7 +861,7 @@ func (s *` + name + `) Handle(payload message.Payload) (err error) {
|
||||||
}
|
}
|
||||||
file.Close()
|
file.Close()
|
||||||
|
|
||||||
registerListenerCode := ` events.RegisterListener((&` + event + `{}).TopicName(), &` + name + `{})
|
registerListenerCode := ` events.RegisterListener((&` + event + `{}).Name(), &` + name + `{})
|
||||||
`
|
`
|
||||||
|
|
||||||
f, err := os.OpenFile(filename, os.O_RDWR, 0600)
|
f, err := os.OpenFile(filename, os.O_RDWR, 0600)
|
||||||
|
|
|
@ -33,7 +33,7 @@ import (
|
||||||
var pubsub *gochannel.GoChannel
|
var pubsub *gochannel.GoChannel
|
||||||
|
|
||||||
type Event interface {
|
type Event interface {
|
||||||
TopicName() string
|
Name() string
|
||||||
}
|
}
|
||||||
|
|
||||||
func InitEvents() (err error) {
|
func InitEvents() (err error) {
|
||||||
|
@ -90,5 +90,5 @@ func Dispatch(event Event) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
msg := message.NewMessage(watermill.NewUUID(), content)
|
msg := message.NewMessage(watermill.NewUUID(), content)
|
||||||
return pubsub.Publish(event.TopicName(), msg)
|
return pubsub.Publish(event.Name(), msg)
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,11 +38,11 @@ func Fake() {
|
||||||
func AssertDispatched(t *testing.T, event Event) {
|
func AssertDispatched(t *testing.T, event Event) {
|
||||||
var found bool
|
var found bool
|
||||||
for _, testEvent := range dispatchedTestEvents {
|
for _, testEvent := range dispatchedTestEvents {
|
||||||
if event.TopicName() == testEvent.TopicName() {
|
if event.Name() == testEvent.Name() {
|
||||||
found = true
|
found = true
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
assert.True(t, found, "Failed to assert "+event.TopicName()+" has been dispatched.")
|
assert.True(t, found, "Failed to assert "+event.Name()+" has been dispatched.")
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,6 @@ type BootedEvent struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// TopicName defines the name for BootedEvent
|
// TopicName defines the name for BootedEvent
|
||||||
func (t *BootedEvent) TopicName() string {
|
func (t *BootedEvent) Name() string {
|
||||||
return "booted"
|
return "booted"
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,7 @@ type TaskCreatedEvent struct {
|
||||||
Doer web.Auth
|
Doer web.Auth
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *TaskCreatedEvent) TopicName() string {
|
func (t *TaskCreatedEvent) Name() string {
|
||||||
return "task.created"
|
return "task.created"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ type TaskUpdatedEvent struct {
|
||||||
Doer web.Auth
|
Doer web.Auth
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *TaskUpdatedEvent) TopicName() string {
|
func (t *TaskUpdatedEvent) Name() string {
|
||||||
return "task.updated"
|
return "task.updated"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ type TaskDeletedEvent struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// TopicName defines the name for TaskDeletedEvent
|
// TopicName defines the name for TaskDeletedEvent
|
||||||
func (t *TaskDeletedEvent) TopicName() string {
|
func (t *TaskDeletedEvent) Name() string {
|
||||||
return "task.deleted"
|
return "task.deleted"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@ type TaskAssigneeCreatedEvent struct {
|
||||||
Doer web.Auth
|
Doer web.Auth
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *TaskAssigneeCreatedEvent) TopicName() string {
|
func (t *TaskAssigneeCreatedEvent) Name() string {
|
||||||
return "task.assignee.created"
|
return "task.assignee.created"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,7 +70,7 @@ type TaskCommentCreatedEvent struct {
|
||||||
Doer web.Auth
|
Doer web.Auth
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *TaskCommentCreatedEvent) TopicName() string {
|
func (t *TaskCommentCreatedEvent) Name() string {
|
||||||
return "task.comment.created"
|
return "task.comment.created"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,7 +83,7 @@ type NamespaceCreatedEvent struct {
|
||||||
Doer web.Auth
|
Doer web.Auth
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *NamespaceCreatedEvent) TopicName() string {
|
func (n *NamespaceCreatedEvent) Name() string {
|
||||||
return "namespace.created"
|
return "namespace.created"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,7 +92,7 @@ type NamespaceUpdatedEvent struct {
|
||||||
Doer web.Auth
|
Doer web.Auth
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *NamespaceUpdatedEvent) TopicName() string {
|
func (n *NamespaceUpdatedEvent) Name() string {
|
||||||
return "namespace.updated"
|
return "namespace.updated"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -103,7 +103,7 @@ type NamespaceDeletedEvent struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// TopicName defines the name for NamespaceDeletedEvent
|
// TopicName defines the name for NamespaceDeletedEvent
|
||||||
func (t *NamespaceDeletedEvent) TopicName() string {
|
func (t *NamespaceDeletedEvent) Name() string {
|
||||||
return "namespace.deleted"
|
return "namespace.deleted"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,7 +116,7 @@ type ListCreatedEvent struct {
|
||||||
Doer web.Auth
|
Doer web.Auth
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *ListCreatedEvent) TopicName() string {
|
func (l *ListCreatedEvent) Name() string {
|
||||||
return "list.created"
|
return "list.created"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -125,7 +125,7 @@ type ListUpdatedEvent struct {
|
||||||
Doer web.Auth
|
Doer web.Auth
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *ListUpdatedEvent) TopicName() string {
|
func (l *ListUpdatedEvent) Name() string {
|
||||||
return "list.updated"
|
return "list.updated"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -134,7 +134,7 @@ type ListDeletedEvent struct {
|
||||||
Doer web.Auth
|
Doer web.Auth
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *ListDeletedEvent) TopicName() string {
|
func (t *ListDeletedEvent) Name() string {
|
||||||
return "list.deleted"
|
return "list.deleted"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -148,7 +148,7 @@ type ListSharedWithUserEvent struct {
|
||||||
Doer web.Auth
|
Doer web.Auth
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *ListSharedWithUserEvent) TopicName() string {
|
func (l *ListSharedWithUserEvent) Name() string {
|
||||||
return "list.shared.user"
|
return "list.shared.user"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -158,7 +158,7 @@ type ListSharedWithTeamEvent struct {
|
||||||
Doer web.Auth
|
Doer web.Auth
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *ListSharedWithTeamEvent) TopicName() string {
|
func (l *ListSharedWithTeamEvent) Name() string {
|
||||||
return "list.shared.team"
|
return "list.shared.team"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -168,7 +168,7 @@ type NamespaceSharedWithUserEvent struct {
|
||||||
Doer web.Auth
|
Doer web.Auth
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *NamespaceSharedWithUserEvent) TopicName() string {
|
func (n *NamespaceSharedWithUserEvent) Name() string {
|
||||||
return "namespace.shared.user"
|
return "namespace.shared.user"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -178,7 +178,7 @@ type NamespaceSharedWithTeamEvent struct {
|
||||||
Doer web.Auth
|
Doer web.Auth
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *NamespaceSharedWithTeamEvent) TopicName() string {
|
func (n *NamespaceSharedWithTeamEvent) Name() string {
|
||||||
return "namespace.shared.team"
|
return "namespace.shared.team"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -192,7 +192,7 @@ type TeamMemberAddedEvent struct {
|
||||||
Doer web.Auth
|
Doer web.Auth
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *TeamMemberAddedEvent) TopicName() string {
|
func (t *TeamMemberAddedEvent) Name() string {
|
||||||
return "team.member.added"
|
return "team.member.added"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -203,7 +203,7 @@ type TeamCreatedEvent struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// TopicName defines the name for TeamCreatedEvent
|
// TopicName defines the name for TeamCreatedEvent
|
||||||
func (t *TeamCreatedEvent) TopicName() string {
|
func (t *TeamCreatedEvent) Name() string {
|
||||||
return "team.created"
|
return "team.created"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -214,6 +214,6 @@ type TeamDeletedEvent struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// TopicName defines the name for TeamDeletedEvent
|
// TopicName defines the name for TeamDeletedEvent
|
||||||
func (t *TeamDeletedEvent) TopicName() string {
|
func (t *TeamDeletedEvent) Name() string {
|
||||||
return "team.deleted"
|
return "team.deleted"
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,14 +24,14 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func RegisterListeners() {
|
func RegisterListeners() {
|
||||||
events.RegisterListener((&ListCreatedEvent{}).TopicName(), &IncreaseListCounter{})
|
events.RegisterListener((&ListCreatedEvent{}).Name(), &IncreaseListCounter{})
|
||||||
events.RegisterListener((&ListDeletedEvent{}).TopicName(), &DecreaseListCounter{})
|
events.RegisterListener((&ListDeletedEvent{}).Name(), &DecreaseListCounter{})
|
||||||
events.RegisterListener((&NamespaceCreatedEvent{}).TopicName(), &IncreaseNamespaceCounter{})
|
events.RegisterListener((&NamespaceCreatedEvent{}).Name(), &IncreaseNamespaceCounter{})
|
||||||
events.RegisterListener((&NamespaceDeletedEvent{}).TopicName(), &DecreaseNamespaceCounter{})
|
events.RegisterListener((&NamespaceDeletedEvent{}).Name(), &DecreaseNamespaceCounter{})
|
||||||
events.RegisterListener((&TaskCreatedEvent{}).TopicName(), &IncreaseTaskCounter{})
|
events.RegisterListener((&TaskCreatedEvent{}).Name(), &IncreaseTaskCounter{})
|
||||||
events.RegisterListener((&TaskDeletedEvent{}).TopicName(), &DecreaseTaskCounter{})
|
events.RegisterListener((&TaskDeletedEvent{}).Name(), &DecreaseTaskCounter{})
|
||||||
events.RegisterListener((&TeamDeletedEvent{}).TopicName(), &DecreaseTeamCounter{})
|
events.RegisterListener((&TeamDeletedEvent{}).Name(), &DecreaseTeamCounter{})
|
||||||
events.RegisterListener((&TeamCreatedEvent{}).TopicName(), &IncreaseTeamCounter{})
|
events.RegisterListener((&TeamCreatedEvent{}).Name(), &IncreaseTeamCounter{})
|
||||||
}
|
}
|
||||||
|
|
||||||
//////
|
//////
|
||||||
|
|
|
@ -22,6 +22,6 @@ type UserCreatedEvent struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// TopicName defines the name for UserCreatedEvent
|
// TopicName defines the name for UserCreatedEvent
|
||||||
func (t *UserCreatedEvent) TopicName() string {
|
func (t *UserCreatedEvent) Name() string {
|
||||||
return "user.created"
|
return "user.created"
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func RegisterListeners() {
|
func RegisterListeners() {
|
||||||
events.RegisterListener((&UserCreatedEvent{}).TopicName(), &IncreaseUserCounter{})
|
events.RegisterListener((&UserCreatedEvent{}).Name(), &IncreaseUserCounter{})
|
||||||
}
|
}
|
||||||
|
|
||||||
///////
|
///////
|
||||||
|
|
Loading…
Reference in New Issue