Skip to content

Commit

Permalink
Rename NotifyJoinMatchCommand to CreateBattleCommand
Browse files Browse the repository at this point in the history
  • Loading branch information
elct9620 committed Mar 21, 2024
1 parent b51bb83 commit b2b58b2
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 19 deletions.
4 changes: 2 additions & 2 deletions cmd/server/wire_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions internal/subscriber/match_changed.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ const (
var _ Subscriber = &MatchChangedSubscriber{}

type MatchChangedSubscriber struct {
notifyJoinMatch *usecase.NotifyJoinMatchCommand
notifyJoinMatch *usecase.CreateBattleCommand
}

func NewMatchChangedSubscriber(notifyJoinMatch *usecase.NotifyJoinMatchCommand) *MatchChangedSubscriber {
func NewMatchChangedSubscriber(notifyJoinMatch *usecase.CreateBattleCommand) *MatchChangedSubscriber {
return &MatchChangedSubscriber{
notifyJoinMatch: notifyJoinMatch,
}
Expand All @@ -46,7 +46,7 @@ func (s *MatchChangedSubscriber) Handler(msg *message.Message) error {
matchId = change.Before.Id
}

_, err := s.notifyJoinMatch.Execute(msg.Context(), &usecase.NotifyJoinMatchInput{
_, err := s.notifyJoinMatch.Execute(msg.Context(), &usecase.CreateBattleInput{
MatchId: matchId,
})
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion internal/subscriber/subscriber.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ type Subscriber interface {
type DatabaseSubscriber Subscriber

func ProvideDatabaseSubscribers(
notifyJoinMatch *usecase.NotifyJoinMatchCommand,
notifyJoinMatch *usecase.CreateBattleCommand,
) []DatabaseSubscriber {
return []DatabaseSubscriber{
NewMatchChangedSubscriber(notifyJoinMatch),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,31 @@ import (
"github.com/elct9620/wvs/pkg/event"
)

type NotifyJoinMatchInput struct {
type CreateBattleInput struct {
MatchId string
}

type NotifyJoinMatchOutput struct {
type CreateBattleOutput struct {
}

var _ Command[*NotifyJoinMatchInput, *NotifyJoinMatchOutput] = &NotifyJoinMatchCommand{}
var _ Command[*CreateBattleInput, *CreateBattleOutput] = &CreateBattleCommand{}

type NotifyJoinMatchCommand struct {
type CreateBattleCommand struct {
matchs MatchRepository
streams StreamRepository
}

func NewNotifyJoinMatchCommand(
func NewCreateBattleCommand(
matchs MatchRepository,
streams StreamRepository,
) *NotifyJoinMatchCommand {
return &NotifyJoinMatchCommand{
) *CreateBattleCommand {
return &CreateBattleCommand{
matchs: matchs,
streams: streams,
}
}

func (c *NotifyJoinMatchCommand) Execute(ctx context.Context, input *NotifyJoinMatchInput) (*NotifyJoinMatchOutput, error) {
func (c *CreateBattleCommand) Execute(ctx context.Context, input *CreateBattleInput) (*CreateBattleOutput, error) {
match, err := c.matchs.Find(ctx, input.MatchId)
if err != nil {
return nil, err
Expand All @@ -48,5 +48,5 @@ func (c *NotifyJoinMatchCommand) Execute(ctx context.Context, input *NotifyJoinM
}
}

return &NotifyJoinMatchOutput{}, nil
return &CreateBattleOutput{}, nil
}
4 changes: 2 additions & 2 deletions internal/usecase/usecase.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ var DefaultSet = wire.NewSet(
wire.Bind(new(Command[*CreateMatchInput, *CreateMatchOutput]), new(*CreateMatchCommand)),
NewSubscribeCommand,
wire.Bind(new(Command[*SubscribeCommandInput, *SubscribeCommandOutput]), new(*SubscribeCommand)),
NewNotifyJoinMatchCommand,
wire.Bind(new(Command[*NotifyJoinMatchInput, *NotifyJoinMatchOutput]), new(*NotifyJoinMatchCommand)),
NewCreateBattleCommand,
wire.Bind(new(Command[*CreateBattleInput, *CreateBattleOutput]), new(*CreateBattleCommand)),
)

type Command[I any, O any] interface {
Expand Down
4 changes: 2 additions & 2 deletions wire_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit b2b58b2

Please sign in to comment.