examples/chat/room_aggregate_gen.go
// Code generated by go generate; DO NOT EDIT.// This file was generated at// 2021-11-19 15:31:40.053991 -0800 PST m=+0.001858260package chat import ( "github.com/inklabs/rangedb" "github.com/inklabs/rangedb/pkg/cqrs") Similar blocks of code found in 2 locations. Consider refactoring.func (a *room) Load(recordIterator rangedb.RecordIterator) { for recordIterator.Next() { if recordIterator.Err() == nil { if event, ok := recordIterator.Record().Data.(rangedb.Event); ok { a.apply(event) } } }} func (a *room) apply(event rangedb.Event) {Similar blocks of code found in 2 locations. Consider refactoring. switch e := event.(type) { case RoomWasOnBoarded: a.roomWasOnBoarded(e) case *RoomWasOnBoarded: a.roomWasOnBoarded(*e) case RoomWasJoined: a.roomWasJoined(e) case *RoomWasJoined: a.roomWasJoined(*e) case MessageWasSentToRoom: a.messageWasSentToRoom(e) case *MessageWasSentToRoom: a.messageWasSentToRoom(*e) case PrivateMessageWasSentToRoom: a.privateMessageWasSentToRoom(e) case *PrivateMessageWasSentToRoom: a.privateMessageWasSentToRoom(*e) case UserWasRemovedFromRoom: a.userWasRemovedFromRoom(e) case *UserWasRemovedFromRoom: a.userWasRemovedFromRoom(*e) case UserWasBannedFromRoom: a.userWasBannedFromRoom(e) case *UserWasBannedFromRoom: a.userWasBannedFromRoom(*e) }} func (a *room) Handle(command cqrs.Command) []rangedb.Event {Similar blocks of code found in 2 locations. Consider refactoring. switch c := command.(type) { case OnBoardRoom: a.onBoardRoom(c) case *OnBoardRoom: a.onBoardRoom(*c) case JoinRoom: a.joinRoom(c) case *JoinRoom: a.joinRoom(*c) case SendMessageToRoom: a.sendMessageToRoom(c) case *SendMessageToRoom: a.sendMessageToRoom(*c) case SendPrivateMessageToRoom: a.sendPrivateMessageToRoom(c) case *SendPrivateMessageToRoom: a.sendPrivateMessageToRoom(*c) case RemoveUserFromRoom: a.removeUserFromRoom(c) case *RemoveUserFromRoom: a.removeUserFromRoom(*c) case BanUserFromRoom: a.banUserFromRoom(c) case *BanUserFromRoom: a.banUserFromRoom(*c) } defer a.resetPendingEvents() return a.pendingEvents} func (a *room) resetPendingEvents() { a.pendingEvents = nil} func (a *room) CommandTypes() []string { return []string{ OnBoardRoom{}.CommandType(), JoinRoom{}.CommandType(), SendMessageToRoom{}.CommandType(), SendPrivateMessageToRoom{}.CommandType(), RemoveUserFromRoom{}.CommandType(), BanUserFromRoom{}.CommandType(), }} func (a *room) raise(events ...rangedb.Event) { a.pendingEvents = append(a.pendingEvents, events...)}