"google.golang.org/protobuf/proto" ) // Cart is an actor to create cart type Cart struct { persistence.Mixin stream *actor.PID state *cart.Items } ΞΫλʔͷӬଓԽΛར༻͢Δ߹ʹ ඞਢ
"google.golang.org/protobuf/proto" ) // Cart is an actor to create cart type Cart struct { persistence.Mixin stream *actor.PID state *cart.Items } $BSUΞΫλʔͷঢ়ଶ
"google.golang.org/protobuf/proto" ) // Cart is an actor to create cart type Cart struct { persistence.Mixin stream *actor.PID state *cart.Items } ϦʔυϞσϧߋ৽ΞΫλʔͳͲ
struct { query mysql.RegistrationItemExecutor } // NewReadModelUpdate is constructor for ReadModelUpdate func NewReadModelUpdate(query mysql.RegistrationItemExecutor) actor.Actor { return &ReadModelUpdate{ query: query, } } // Receive is sent messages to be processed from the mailbox associated with the instance of the actor func (u *ReadModelUpdate) Receive(ctx actor.Context) { switch msg := ctx.Message().(type) { case *event.ItemAdded: // ΠϕϯτΛಡΈࠐΜͰɺRead ModelΛߋ৽͢Δ // ͜͜ͰRead ModelʹΞΠςϜ͕ଘࡏ͠ͳ͍߹ʹ࡞͢Δ෩ err := u.query.AddItemIfNotExists(context.Background(), mysql.AddItemParams{ Name: msg.ItemName, ID: msg.ItemID, }) if err != nil { // Τϥʔ͕ൃੜͨ͠߹ϩάΛग़ྗ͢Δ ctx.Logger().Error(err.Error()) return } } }