From fb111ebf97c4772e0edcf077b989ffad6fc84773 Mon Sep 17 00:00:00 2001 From: matst80 Date: Fri, 10 Oct 2025 18:44:31 +0000 Subject: [PATCH] cleanup and http proxy --- Makefile | 2 +- cart_state_mapper.go | 212 ----- grpc_integration_test.go | 115 --- grpc_server.go | 168 ---- multi_node_ownership_test.go | 180 ---- multi_node_three_test.go | 301 ------- proto/cart_actor.pb.go | 1545 ---------------------------------- proto/cart_actor.proto | 187 ---- proto/cart_actor_grpc.pb.go | 473 ----------- synced-pool.go | 8 +- 10 files changed, 4 insertions(+), 3187 deletions(-) delete mode 100644 cart_state_mapper.go delete mode 100644 grpc_integration_test.go delete mode 100644 multi_node_ownership_test.go delete mode 100644 multi_node_three_test.go delete mode 100644 proto/cart_actor.pb.go delete mode 100644 proto/cart_actor.proto delete mode 100644 proto/cart_actor_grpc.pb.go diff --git a/Makefile b/Makefile index 4cf839b..b688d69 100644 --- a/Makefile +++ b/Makefile @@ -19,7 +19,7 @@ MODULE_PATH := git.tornberg.me/go-cart-actor PROTO_DIR := proto -PROTOS := $(PROTO_DIR)/messages.proto $(PROTO_DIR)/cart_actor.proto $(PROTO_DIR)/control_plane.proto +PROTOS := $(PROTO_DIR)/messages.proto $(PROTO_DIR)/control_plane.proto # Allow override: make PROTOC=/path/to/protoc PROTOC ?= protoc diff --git a/cart_state_mapper.go b/cart_state_mapper.go deleted file mode 100644 index 1043f51..0000000 --- a/cart_state_mapper.go +++ /dev/null @@ -1,212 +0,0 @@ -package main - -import ( - messages "git.tornberg.me/go-cart-actor/proto" -) - -// cart_state_mapper.go -// -// Utilities to translate between internal CartGrain state and the gRPC -// (typed) protobuf representation CartState. This replaces the previous -// JSON blob framing and enables type-safe replies over gRPC, as well as -// internal reuse for HTTP handlers without an extra marshal / unmarshal -// hop (you can marshal CartState directly for JSON responses if desired). -// -// Only the one‑way mapping (CartGrain -> CartState) is strictly required -// for mutation / state replies. A reverse helper is included in case -// future features (e.g. snapshot import, replay, or migration) need it. - -// ToCartState converts the in‑memory CartGrain into a protobuf CartState. -func ToCartState(c *CartGrain) *messages.CartState { - if c == nil { - return nil - } - - items := make([]*messages.CartItemState, 0, len(c.Items)) - for _, it := range c.Items { - if it == nil { - continue - } - itemDiscountPerUnit := max(0, it.OrgPrice-it.Price) - itemTotalDiscount := itemDiscountPerUnit * int64(it.Quantity) - - items = append(items, &messages.CartItemState{ - Id: int64(it.Id), - ItemId: int64(it.ItemId), - Sku: it.Sku, - Name: it.Name, - Price: it.Price, - Qty: int32(it.Quantity), - TotalPrice: it.TotalPrice, - TotalTax: it.TotalTax, - OrgPrice: it.OrgPrice, - TaxRate: int32(it.TaxRate), - TotalDiscount: itemTotalDiscount, - Brand: it.Brand, - Category: it.Category, - Category2: it.Category2, - Category3: it.Category3, - Category4: it.Category4, - Category5: it.Category5, - Image: it.Image, - Type: it.ArticleType, - SellerId: it.SellerId, - SellerName: it.SellerName, - Disclaimer: it.Disclaimer, - Outlet: deref(it.Outlet), - StoreId: deref(it.StoreId), - Stock: int32(it.Stock), - }) - } - - deliveries := make([]*messages.DeliveryState, 0, len(c.Deliveries)) - for _, d := range c.Deliveries { - if d == nil { - continue - } - itemIds := make([]int64, 0, len(d.Items)) - for _, id := range d.Items { - itemIds = append(itemIds, int64(id)) - } - var pp *messages.PickupPoint - if d.PickupPoint != nil { - // Copy to avoid accidental shared mutation (proto points are fine but explicit). - pp = &messages.PickupPoint{ - Id: d.PickupPoint.Id, - Name: d.PickupPoint.Name, - Address: d.PickupPoint.Address, - City: d.PickupPoint.City, - Zip: d.PickupPoint.Zip, - Country: d.PickupPoint.Country, - } - } - deliveries = append(deliveries, &messages.DeliveryState{ - Id: int64(d.Id), - Provider: d.Provider, - Price: d.Price, - Items: itemIds, - PickupPoint: pp, - }) - } - - return &messages.CartState{ - Id: c.Id.String(), - Items: items, - TotalPrice: c.TotalPrice, - TotalTax: c.TotalTax, - TotalDiscount: c.TotalDiscount, - Deliveries: deliveries, - PaymentInProgress: c.PaymentInProgress, - OrderReference: c.OrderReference, - PaymentStatus: c.PaymentStatus, - } -} - -// FromCartState merges a protobuf CartState into an existing CartGrain. -// This is optional and primarily useful for snapshot import or testing. -func FromCartState(cs *messages.CartState, g *CartGrain) *CartGrain { - if cs == nil { - return g - } - if g == nil { - g = &CartGrain{} - } - g.Id = ToCartId(cs.Id) - g.TotalPrice = cs.TotalPrice - g.TotalTax = cs.TotalTax - g.TotalDiscount = cs.TotalDiscount - g.PaymentInProgress = cs.PaymentInProgress - g.OrderReference = cs.OrderReference - g.PaymentStatus = cs.PaymentStatus - - // Items - g.Items = g.Items[:0] - for _, it := range cs.Items { - if it == nil { - continue - } - outlet := toPtr(it.Outlet) - storeId := toPtr(it.StoreId) - g.Items = append(g.Items, &CartItem{ - Id: int(it.Id), - ItemId: int(it.ItemId), - Sku: it.Sku, - Name: it.Name, - Price: it.Price, - Quantity: int(it.Qty), - TotalPrice: it.TotalPrice, - TotalTax: it.TotalTax, - OrgPrice: it.OrgPrice, - TaxRate: int(it.TaxRate), - Brand: it.Brand, - Category: it.Category, - Category2: it.Category2, - Category3: it.Category3, - Category4: it.Category4, - Category5: it.Category5, - Image: it.Image, - ArticleType: it.Type, - SellerId: it.SellerId, - SellerName: it.SellerName, - Disclaimer: it.Disclaimer, - Outlet: outlet, - StoreId: storeId, - Stock: StockStatus(it.Stock), - // Tax, TaxRate already set via Price / Totals if needed - }) - if it.Id > int64(g.lastItemId) { - g.lastItemId = int(it.Id) - } - } - - // Deliveries - g.Deliveries = g.Deliveries[:0] - for _, d := range cs.Deliveries { - if d == nil { - continue - } - - intIds := make([]int, 0, len(d.Items)) - for _, id := range d.Items { - intIds = append(intIds, int(id)) - } - var pp *messages.PickupPoint - if d.PickupPoint != nil { - pp = &messages.PickupPoint{ - Id: d.PickupPoint.Id, - Name: d.PickupPoint.Name, - Address: d.PickupPoint.Address, - City: d.PickupPoint.City, - Zip: d.PickupPoint.Zip, - Country: d.PickupPoint.Country, - } - } - g.Deliveries = append(g.Deliveries, &CartDelivery{ - Id: int(d.Id), - Provider: d.Provider, - Price: d.Price, - Items: intIds, - PickupPoint: pp, - }) - if d.Id > int64(g.lastDeliveryId) { - g.lastDeliveryId = int(d.Id) - } - } - - return g -} - -// Helper to safely de-reference optional string pointers to value or "". -func deref(p *string) string { - if p == nil { - return "" - } - return *p -} - -func toPtr(s string) *string { - if s == "" { - return nil - } - return &s -} diff --git a/grpc_integration_test.go b/grpc_integration_test.go deleted file mode 100644 index 863bd7f..0000000 --- a/grpc_integration_test.go +++ /dev/null @@ -1,115 +0,0 @@ -package main - -import ( - "context" - "fmt" - "testing" - "time" - - messages "git.tornberg.me/go-cart-actor/proto" - "google.golang.org/grpc" -) - -// TestCartActorMutationAndState validates end-to-end gRPC mutation + state retrieval -// against a locally started gRPC server (single-node scenario). -// This test uses the new per-mutation AddItem RPC (breaking v2 API) to avoid external product fetch logic -// fetching logic (FetchItem) which would require network I/O. -func TestCartActorMutationAndState(t *testing.T) { - // Setup local grain pool + synced pool (no discovery, single host) - pool := NewGrainLocalPool(1024, time.Minute, spawn) - synced, err := NewSyncedPool(pool, "127.0.0.1", nil) - if err != nil { - t.Fatalf("NewSyncedPool error: %v", err) - } - - // Start gRPC server (CartActor + ControlPlane) on :1337 - grpcSrv, err := StartGRPCServer(":1337", pool, synced) - if err != nil { - t.Fatalf("StartGRPCServer error: %v", err) - } - defer grpcSrv.GracefulStop() - - // Dial the local server - ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second) - defer cancel() - conn, err := grpc.DialContext(ctx, "127.0.0.1:1337", - grpc.WithInsecure(), - grpc.WithBlock(), - ) - if err != nil { - t.Fatalf("grpc.Dial error: %v", err) - } - defer conn.Close() - - cartClient := messages.NewCartActorClient(conn) - - // Create a short cart id (<=16 chars so it fits into the fixed CartId 16-byte array cleanly) - cartID := fmt.Sprintf("cart-%d", time.Now().UnixNano()) - - // Build an AddItem payload (bypasses FetchItem to keep test deterministic) - addItem := &messages.AddItem{ - ItemId: 1, - Quantity: 1, - Price: 1000, - OrgPrice: 1000, - Sku: "test-sku", - Name: "Test SKU", - Image: "/img.png", - Stock: 2, // InStock - Tax: 2500, - Country: "se", - } - - // Issue AddItem RPC directly (breaking v2 API) - addResp, err := cartClient.AddItem(context.Background(), &messages.AddItemRequest{ - CartId: cartID, - ClientTimestamp: time.Now().Unix(), - Payload: addItem, - }) - if err != nil { - t.Fatalf("AddItem RPC error: %v", err) - } - if addResp.StatusCode != 200 { - t.Fatalf("AddItem returned non-200 status: %d, error: %s", addResp.StatusCode, addResp.GetError()) - } - - // Validate the response state (from AddItem) - state := addResp.GetState() - if state == nil { - t.Fatalf("AddItem response state is nil") - } - - // (Removed obsolete Mutate response handling) - - if len(state.Items) != 1 { - t.Fatalf("Expected 1 item after AddItem, got %d", len(state.Items)) - } - if state.Items[0].Sku != "test-sku" { - t.Fatalf("Unexpected item SKU: %s", state.Items[0].Sku) - } - - // Issue GetState RPC - getResp, err := cartClient.GetState(context.Background(), &messages.StateRequest{ - CartId: cartID, - }) - if err != nil { - t.Fatalf("GetState RPC error: %v", err) - } - if getResp.StatusCode != 200 { - t.Fatalf("GetState returned non-200 status: %d, error: %s", getResp.StatusCode, getResp.GetError()) - } - - state2 := getResp.GetState() - if state2 == nil { - t.Fatalf("GetState response state is nil") - } - - if len(state2.Items) != 1 { - t.Fatalf("Expected 1 item in GetState, got %d", len(state2.Items)) - } - if state2.Items[0].Sku != "test-sku" { - t.Fatalf("Unexpected SKU in GetState: %s", state2.Items[0].Sku) - } -} - -// Legacy serialization helper removed (oneof envelope used directly) diff --git a/grpc_server.go b/grpc_server.go index 24a5876..a4a849c 100644 --- a/grpc_server.go +++ b/grpc_server.go @@ -16,7 +16,6 @@ import ( // cartActorGRPCServer implements the CartActor and ControlPlane gRPC services. // It delegates cart operations to a grain pool and cluster operations to a synced pool. type cartActorGRPCServer struct { - messages.UnimplementedCartActorServer messages.UnimplementedControlPlaneServer pool GrainPool // For cart state mutations and queries @@ -31,172 +30,6 @@ func NewCartActorGRPCServer(pool GrainPool, syncedPool *SyncedPool) *cartActorGR } } -// applyMutation routes a single cart mutation to the target grain (used by per-mutation RPC handlers). -func (s *cartActorGRPCServer) applyMutation(cartID string, mutation interface{}) *messages.CartMutationReply { - // Canonicalize or preserve legacy id (do NOT hash-rewrite legacy textual ids) - cid, _, wasBase62, cerr := CanonicalizeOrLegacy(cartID) - if cerr != nil { - return &messages.CartMutationReply{ - StatusCode: 500, - Result: &messages.CartMutationReply_Error{Error: fmt.Sprintf("cart_id canonicalization failed: %v", cerr)}, - ServerTimestamp: time.Now().Unix(), - } - } - _ = wasBase62 // placeholder; future: propagate canonical id in reply metadata - legacy := CartIDToLegacy(cid) - grain, err := s.pool.Apply(legacy, mutation) - if err != nil { - return &messages.CartMutationReply{ - StatusCode: 500, - Result: &messages.CartMutationReply_Error{Error: err.Error()}, - ServerTimestamp: time.Now().Unix(), - } - } - cartState := ToCartState(grain) - return &messages.CartMutationReply{ - StatusCode: 200, - Result: &messages.CartMutationReply_State{State: cartState}, - ServerTimestamp: time.Now().Unix(), - } -} - -func (s *cartActorGRPCServer) AddRequest(ctx context.Context, req *messages.AddRequestRequest) (*messages.CartMutationReply, error) { - if req.GetCartId() == "" { - return &messages.CartMutationReply{ - StatusCode: 400, - Result: &messages.CartMutationReply_Error{Error: "cart_id is required"}, - ServerTimestamp: time.Now().Unix(), - }, nil - } - return s.applyMutation(req.GetCartId(), req.GetPayload()), nil -} - -func (s *cartActorGRPCServer) AddItem(ctx context.Context, req *messages.AddItemRequest) (*messages.CartMutationReply, error) { - if req.GetCartId() == "" { - return &messages.CartMutationReply{ - StatusCode: 400, - Result: &messages.CartMutationReply_Error{Error: "cart_id is required"}, - ServerTimestamp: time.Now().Unix(), - }, nil - } - return s.applyMutation(req.GetCartId(), req.GetPayload()), nil -} - -func (s *cartActorGRPCServer) RemoveItem(ctx context.Context, req *messages.RemoveItemRequest) (*messages.CartMutationReply, error) { - if req.GetCartId() == "" { - return &messages.CartMutationReply{ - StatusCode: 400, - Result: &messages.CartMutationReply_Error{Error: "cart_id is required"}, - ServerTimestamp: time.Now().Unix(), - }, nil - } - return s.applyMutation(req.GetCartId(), req.GetPayload()), nil -} - -func (s *cartActorGRPCServer) RemoveDelivery(ctx context.Context, req *messages.RemoveDeliveryRequest) (*messages.CartMutationReply, error) { - if req.GetCartId() == "" { - return &messages.CartMutationReply{ - StatusCode: 400, - Result: &messages.CartMutationReply_Error{Error: "cart_id is required"}, - ServerTimestamp: time.Now().Unix(), - }, nil - } - return s.applyMutation(req.GetCartId(), req.GetPayload()), nil -} - -func (s *cartActorGRPCServer) ChangeQuantity(ctx context.Context, req *messages.ChangeQuantityRequest) (*messages.CartMutationReply, error) { - if req.GetCartId() == "" { - return &messages.CartMutationReply{ - StatusCode: 400, - Result: &messages.CartMutationReply_Error{Error: "cart_id is required"}, - ServerTimestamp: time.Now().Unix(), - }, nil - } - return s.applyMutation(req.GetCartId(), req.GetPayload()), nil -} - -func (s *cartActorGRPCServer) SetDelivery(ctx context.Context, req *messages.SetDeliveryRequest) (*messages.CartMutationReply, error) { - if req.GetCartId() == "" { - return &messages.CartMutationReply{ - StatusCode: 400, - Result: &messages.CartMutationReply_Error{Error: "cart_id is required"}, - ServerTimestamp: time.Now().Unix(), - }, nil - } - return s.applyMutation(req.GetCartId(), req.GetPayload()), nil -} - -func (s *cartActorGRPCServer) SetPickupPoint(ctx context.Context, req *messages.SetPickupPointRequest) (*messages.CartMutationReply, error) { - if req.GetCartId() == "" { - return &messages.CartMutationReply{ - StatusCode: 400, - Result: &messages.CartMutationReply_Error{Error: "cart_id is required"}, - ServerTimestamp: time.Now().Unix(), - }, nil - } - return s.applyMutation(req.GetCartId(), req.GetPayload()), nil -} - -/* -Checkout RPC removed. Checkout is handled at the HTTP layer (PoolServer.HandleCheckout). -*/ - -func (s *cartActorGRPCServer) SetCartItems(ctx context.Context, req *messages.SetCartItemsRequest) (*messages.CartMutationReply, error) { - if req.GetCartId() == "" { - return &messages.CartMutationReply{ - StatusCode: 400, - Result: &messages.CartMutationReply_Error{Error: "cart_id is required"}, - ServerTimestamp: time.Now().Unix(), - }, nil - } - return s.applyMutation(req.GetCartId(), req.GetPayload()), nil -} - -func (s *cartActorGRPCServer) OrderCompleted(ctx context.Context, req *messages.OrderCompletedRequest) (*messages.CartMutationReply, error) { - if req.GetCartId() == "" { - return &messages.CartMutationReply{ - StatusCode: 400, - Result: &messages.CartMutationReply_Error{Error: "cart_id is required"}, - ServerTimestamp: time.Now().Unix(), - }, nil - } - return s.applyMutation(req.GetCartId(), req.GetPayload()), nil -} - -// GetState retrieves the current state of a cart grain. -func (s *cartActorGRPCServer) GetState(ctx context.Context, req *messages.StateRequest) (*messages.StateReply, error) { - if req.GetCartId() == "" { - return &messages.StateReply{ - StatusCode: 400, - Result: &messages.StateReply_Error{Error: "cart_id is required"}, - }, nil - } - // Canonicalize / upgrade incoming cart id (preserve legacy strings) - cid, _, _, cerr := CanonicalizeOrLegacy(req.GetCartId()) - if cerr != nil { - return &messages.StateReply{ - StatusCode: 500, - Result: &messages.StateReply_Error{Error: fmt.Sprintf("cart_id canonicalization failed: %v", cerr)}, - }, nil - } - legacy := CartIDToLegacy(cid) - - grain, err := s.pool.Get(legacy) - if err != nil { - return &messages.StateReply{ - StatusCode: 500, - Result: &messages.StateReply_Error{Error: err.Error()}, - }, nil - } - - cartState := ToCartState(grain) - - return &messages.StateReply{ - StatusCode: 200, - Result: &messages.StateReply_State{State: cartState}, - }, nil -} - // ControlPlane: Ping func (s *cartActorGRPCServer) Ping(ctx context.Context, _ *messages.Empty) (*messages.PingReply, error) { // Expose cart owner cookie (first-touch owner = this host) for HTTP gateways translating gRPC metadata. @@ -269,7 +102,6 @@ func StartGRPCServer(addr string, pool GrainPool, syncedPool *SyncedPool) (*grpc grpcServer := grpc.NewServer() server := NewCartActorGRPCServer(pool, syncedPool) - messages.RegisterCartActorServer(grpcServer, server) messages.RegisterControlPlaneServer(grpcServer, server) reflection.Register(grpcServer) diff --git a/multi_node_ownership_test.go b/multi_node_ownership_test.go deleted file mode 100644 index 1f9d937..0000000 --- a/multi_node_ownership_test.go +++ /dev/null @@ -1,180 +0,0 @@ -package main - -import ( - "context" - "fmt" - "testing" - "time" - - messages "git.tornberg.me/go-cart-actor/proto" - "google.golang.org/grpc" -) - -// TestMultiNodeOwnershipNegotiation spins up two gRPC servers (nodeA, nodeB), -// manually links their SyncedPools (bypassing AddRemote's fixed port assumption), -// and verifies that only one node becomes the owner of a new cart while the -// other can still apply a mutation via the remote proxy path. -// -// NOTE: -// - We manually inject RemoteHostGRPC entries because AddRemote() hard-codes -// port 1337; to run two distinct servers concurrently we need distinct ports. -// - This test asserts single ownership consistency rather than the complete -// quorum semantics (which depend on real discovery + AddRemote). -func TestMultiNodeOwnershipNegotiation(t *testing.T) { - // Allocate distinct ports for the two nodes. - const ( - addrA = "127.0.0.1:18081" - addrB = "127.0.0.1:18082" - hostA = "nodeA" - hostB = "nodeB" - ) - - // Create local grain pools. - poolA := NewGrainLocalPool(1024, time.Minute, spawn) - poolB := NewGrainLocalPool(1024, time.Minute, spawn) - - // Create synced pools (no discovery). - syncedA, err := NewSyncedPool(poolA, hostA, nil) - if err != nil { - t.Fatalf("nodeA NewSyncedPool error: %v", err) - } - syncedB, err := NewSyncedPool(poolB, hostB, nil) - if err != nil { - t.Fatalf("nodeB NewSyncedPool error: %v", err) - } - - // Start gRPC servers (CartActor + ControlPlane) on different ports. - grpcSrvA, err := StartGRPCServer(addrA, poolA, syncedA) - if err != nil { - t.Fatalf("StartGRPCServer A error: %v", err) - } - defer grpcSrvA.GracefulStop() - - grpcSrvB, err := StartGRPCServer(addrB, poolB, syncedB) - if err != nil { - t.Fatalf("StartGRPCServer B error: %v", err) - } - defer grpcSrvB.GracefulStop() - - // Helper to connect one pool to the other's server (manual AddRemote equivalent). - link := func(src *SyncedPool, remoteHost, remoteAddr string) { - ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second) - defer cancel() - conn, dialErr := grpc.DialContext(ctx, remoteAddr, grpc.WithInsecure(), grpc.WithBlock()) - if dialErr != nil { - t.Fatalf("dial %s (%s) failed: %v", remoteHost, remoteAddr, dialErr) - } - cartClient := messages.NewCartActorClient(conn) - controlClient := messages.NewControlPlaneClient(conn) - - src.mu.Lock() - src.remoteHosts[remoteHost] = &RemoteHostGRPC{ - Host: remoteHost, - Conn: conn, - CartClient: cartClient, - ControlClient: controlClient, - } - src.mu.Unlock() - } - - // Cross-link the two pools. - link(syncedA, hostB, addrB) - link(syncedB, hostA, addrA) - - // Ring-based ownership removed; no ring refresh needed. - - // Allow brief stabilization (control plane pings / no real negotiation needed here). - time.Sleep(200 * time.Millisecond) - - // Create a deterministic cart id for test readability. - cartID := ToCartId(fmt.Sprintf("cart-%d", time.Now().UnixNano())) - - // Mutation payload (ring-determined ownership; no assumption about which node owns). - addItem := &messages.AddItem{ - ItemId: 1, - Quantity: 1, - Price: 1500, - OrgPrice: 1500, - Sku: "sku-test-multi", - Name: "Multi Node Test", - Image: "/test.png", - Stock: 2, - Tax: 2500, - Country: "se", - } - - // Determine ring owner and set primary / secondary references. - ownerHost := syncedA.DebugOwnerHost(cartID) - var ownerSynced, otherSynced *SyncedPool - var ownerPool, otherPool *GrainLocalPool - switch ownerHost { - case hostA: - ownerSynced, ownerPool = syncedA, poolA - otherSynced, otherPool = syncedB, poolB - case hostB: - ownerSynced, ownerPool = syncedB, poolB - otherSynced, otherPool = syncedA, poolA - default: - t.Fatalf("unexpected ring owner %s (expected %s or %s)", ownerHost, hostA, hostB) - } - - // Apply mutation on the ring-designated owner. - if _, err := ownerSynced.Apply(cartID, addItem); err != nil { - t.Fatalf("owner %s Apply addItem error: %v", ownerHost, err) - } - - // Validate owner pool has the grain and the other does not. - if _, ok := ownerPool.GetGrains()[cartID]; !ok { - t.Fatalf("expected owner %s to have local grain", ownerHost) - } - if _, ok := otherPool.GetGrains()[cartID]; ok { - t.Fatalf("non-owner unexpectedly holds local grain") - } - - // Prepare change mutation to be applied from the non-owner (should route remotely). - change := &messages.ChangeQuantity{ - Id: 1, // line id after first AddItem - Quantity: 2, - } - // Apply remotely via the non-owner. - if _, err := otherSynced.Apply(cartID, change); err != nil { - t.Fatalf("non-owner remote Apply changeQuantity error: %v", err) - } - - // Remote re-mutation already performed via otherSynced; removed duplicate block. - - // NodeB local grain assertion: - // Only assert absence if nodeB is NOT the ring-designated owner. If nodeB is the owner, - // it is expected to have a local grain (previous generic ownership assertions already ran). - if ownerHost != hostB { - if _, local := poolB.GetGrains()[cartID]; local { - t.Fatalf("nodeB unexpectedly created local grain (ownership duplication)") - } - } - - // Fetch state from nodeB to ensure we see updated quantity (2). - grainStateB, err := syncedB.Get(cartID) - if err != nil { - t.Fatalf("nodeB Get error: %v", err) - } - if len(grainStateB.Items) != 1 || grainStateB.Items[0].Quantity != 2 { - t.Fatalf("nodeB observed inconsistent state: items=%d qty=%d (expected 1 / 2)", - len(grainStateB.Items), - func() int { - if len(grainStateB.Items) == 0 { - return -1 - } - return grainStateB.Items[0].Quantity - }(), - ) - } - - // Cross-check from nodeA (authoritative) to ensure state matches. - grainStateA, err := syncedA.Get(cartID) - if err != nil { - t.Fatalf("nodeA Get error: %v", err) - } - if grainStateA.Items[0].Quantity != 2 { - t.Fatalf("nodeA authoritative state mismatch: expected qty=2 got %d", grainStateA.Items[0].Quantity) - } -} diff --git a/multi_node_three_test.go b/multi_node_three_test.go deleted file mode 100644 index 9119ffa..0000000 --- a/multi_node_three_test.go +++ /dev/null @@ -1,301 +0,0 @@ -package main - -import ( - "context" - "fmt" - "testing" - "time" - - messages "git.tornberg.me/go-cart-actor/proto" - "google.golang.org/grpc" -) - -// TestThreeNodeMajorityOwnership validates ring-determined ownership and routing -// in a 3-node cluster (A,B,C) using the consistent hashing ring (no quorum RPC). -// The previous ConfirmOwner / quorum semantics have been removed; ownership is -// deterministic and derived from the ring. -// -// It validates: -// 1. The ring selects exactly one primary owner for a new cart. -// 2. Other nodes (B,C) do NOT create local grains for the cart. -// 3. Remote proxies are installed lazily so remote mutations can route. -// 4. A remote mutation from one non-owner updates state visible on another. -// 5. Authoritative state on the owner matches remote observations. -// 6. (Future) This scaffolds replication tests when RF>1 is enabled. -// -// (Legacy comments about ConfirmOwner acceptance thresholds have been removed.) -// (Function name retained for historical continuity.) -func TestThreeNodeMajorityOwnership(t *testing.T) { - const ( - addrA = "127.0.0.1:18181" - addrB = "127.0.0.1:18182" - addrC = "127.0.0.1:18183" - hostA = "nodeA3" - hostB = "nodeB3" - hostC = "nodeC3" - ) - - // Local grain pools - poolA := NewGrainLocalPool(1024, time.Minute, spawn) - poolB := NewGrainLocalPool(1024, time.Minute, spawn) - poolC := NewGrainLocalPool(1024, time.Minute, spawn) - - // Synced pools (no discovery) - syncedA, err := NewSyncedPool(poolA, hostA, nil) - if err != nil { - t.Fatalf("nodeA NewSyncedPool error: %v", err) - } - syncedB, err := NewSyncedPool(poolB, hostB, nil) - if err != nil { - t.Fatalf("nodeB NewSyncedPool error: %v", err) - } - syncedC, err := NewSyncedPool(poolC, hostC, nil) - if err != nil { - t.Fatalf("nodeC NewSyncedPool error: %v", err) - } - - // Start gRPC servers - grpcSrvA, err := StartGRPCServer(addrA, poolA, syncedA) - if err != nil { - t.Fatalf("StartGRPCServer A error: %v", err) - } - defer grpcSrvA.GracefulStop() - grpcSrvB, err := StartGRPCServer(addrB, poolB, syncedB) - if err != nil { - t.Fatalf("StartGRPCServer B error: %v", err) - } - defer grpcSrvB.GracefulStop() - grpcSrvC, err := StartGRPCServer(addrC, poolC, syncedC) - if err != nil { - t.Fatalf("StartGRPCServer C error: %v", err) - } - defer grpcSrvC.GracefulStop() - - // Helper for manual cross-link (since AddRemote assumes fixed port) - link := func(src *SyncedPool, remoteHost, remoteAddr string) { - ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second) - defer cancel() - conn, dialErr := grpc.DialContext(ctx, remoteAddr, grpc.WithInsecure(), grpc.WithBlock()) - if dialErr != nil { - t.Fatalf("dial %s (%s) failed: %v", remoteHost, remoteAddr, dialErr) - } - cartClient := messages.NewCartActorClient(conn) - controlClient := messages.NewControlPlaneClient(conn) - - src.mu.Lock() - src.remoteHosts[remoteHost] = &RemoteHostGRPC{ - Host: remoteHost, - Conn: conn, - CartClient: cartClient, - ControlClient: controlClient, - } - src.mu.Unlock() - } - - // Full mesh (each node knows all others) - link(syncedA, hostB, addrB) - link(syncedA, hostC, addrC) - - link(syncedB, hostA, addrA) - link(syncedB, hostC, addrC) - - link(syncedC, hostA, addrA) - link(syncedC, hostB, addrB) - - // Ring-based ownership removed; no ring refresh needed. - - // Allow brief stabilization - time.Sleep(200 * time.Millisecond) - - // Deterministic-ish cart id - cartID := ToCartId(fmt.Sprintf("cart3-%d", time.Now().UnixNano())) - - addItem := &messages.AddItem{ - ItemId: 10, - Quantity: 1, - Price: 5000, - OrgPrice: 5000, - Sku: "sku-3node", - Name: "Three Node Test", - Image: "/t.png", - Stock: 10, - Tax: 2500, - Country: "se", - } - - // Determine ring-designated owner (may be any of the three hosts) - ownerPre := syncedA.DebugOwnerHost(cartID) - if ownerPre != hostA && ownerPre != hostB && ownerPre != hostC { - t.Fatalf("ring returned unexpected owner %s (not in set {%s,%s,%s})", ownerPre, hostA, hostB, hostC) - } - var ownerSynced *SyncedPool - var ownerPool *GrainLocalPool - switch ownerPre { - case hostA: - ownerSynced, ownerPool = syncedA, poolA - case hostB: - ownerSynced, ownerPool = syncedB, poolB - case hostC: - ownerSynced, ownerPool = syncedC, poolC - } - // Pick two distinct non-owner nodes for remote mutation assertions - var remote1Synced, remote2Synced *SyncedPool - switch ownerPre { - case hostA: - remote1Synced, remote2Synced = syncedB, syncedC - case hostB: - remote1Synced, remote2Synced = syncedA, syncedC - case hostC: - remote1Synced, remote2Synced = syncedA, syncedB - } - - // Apply on the ring-designated owner - if _, err := ownerSynced.Apply(cartID, addItem); err != nil { - t.Fatalf("owner %s Apply addItem error: %v", ownerPre, err) - } - - // Small wait for remote proxy spawn (ring ownership already deterministic) - time.Sleep(150 * time.Millisecond) - - // Assert only nodeA has local grain - localCount := 0 - if _, ok := poolA.GetGrains()[cartID]; ok { - localCount++ - } - if _, ok := poolB.GetGrains()[cartID]; ok { - localCount++ - } - if _, ok := poolC.GetGrains()[cartID]; ok { - localCount++ - } - if localCount != 1 { - t.Fatalf("expected exactly 1 local grain, got %d", localCount) - } - if _, ok := ownerPool.GetGrains()[cartID]; !ok { - t.Fatalf("expected owner %s to hold local grain", ownerPre) - } - - // First-touch ownership: remote mutation claims ownership on first access (no remote proxies). - - // Issue remote mutation from one non-owner -> ChangeQuantity (increase) - change := &messages.ChangeQuantity{ - Id: 1, - Quantity: 3, - } - if _, err := remote1Synced.Apply(cartID, change); err != nil { - t.Fatalf("remote mutation (remote1) changeQuantity error: %v", err) - } - - // Validate updated state visible via nodeC - stateC, err := remote2Synced.Get(cartID) - if err != nil { - t.Fatalf("nodeC Get error: %v", err) - } - if len(stateC.Items) != 1 || stateC.Items[0].Quantity != 3 { - t.Fatalf("nodeC observed state mismatch: items=%d qty=%d (expected 1 / 3)", - len(stateC.Items), - func() int { - if len(stateC.Items) == 0 { - return -1 - } - return stateC.Items[0].Quantity - }(), - ) - } - - // Cross-check authoritative nodeA - stateA, err := syncedA.Get(cartID) - if err != nil { - t.Fatalf("nodeA Get error: %v", err) - } - if stateA.Items[0].Quantity != 3 { - t.Fatalf("nodeA authoritative state mismatch: expected qty=3 got %d", stateA.Items[0].Quantity) - } -} - -// TestThreeNodeDiscoveryMajorityOwnership (placeholder) -// This test is a scaffold demonstrating how a MockDiscovery would be wired -// once AddRemote supports host:port (currently hard-coded to :1337). -// It is skipped to avoid flakiness / false negatives until the production -// AddRemote logic is enhanced to parse dynamic ports or the test harness -// provides consistent port mapping. -func TestThreeNodeDiscoveryMajorityOwnership(t *testing.T) { - t.Skip("Pending enhancement: AddRemote needs host:port support to fully exercise discovery-based multi-node linking") - // Example skeleton (non-functional with current AddRemote implementation): - // - // md := NewMockDiscovery([]string{"nodeB3", "nodeC3"}) - // poolA := NewGrainLocalPool(1024, time.Minute, spawn) - // syncedA, err := NewSyncedPool(poolA, "nodeA3", md) - // if err != nil { - // t.Fatalf("NewSyncedPool with mock discovery error: %v", err) - // } - // // Start server for nodeA (would also need servers for nodeB3/nodeC3 on expected ports) - // // grpcSrvA, _ := StartGRPCServer(":1337", poolA, syncedA) - // // defer grpcSrvA.GracefulStop() - // - // // Dynamically add a host via discovery - // // md.AddHost("nodeB3") - // // time.Sleep(100 * time.Millisecond) // allow AddRemote attempt - // - // // Assertions would verify syncedA.remoteHosts contains "nodeB3" -} - -// TestHostRemovalAndErrorWithMockDiscovery validates behavior when: -// 1. Discovery reports a host that cannot be dialed (AddRemote error path) -// 2. That host is then removed (Deleted event) without leaving residual state -// 3. A second failing host is added afterward (ensuring watcher still processes events) -// -// NOTE: Because AddRemote currently hard-codes :1337 and we are NOT starting a -// real server for the bogus hosts, the dial will fail and the remote host should -// never appear in remoteHosts. This intentionally exercises the error logging -// path: "AddRemote: dial ... failed". -func TestHostRemovalAndErrorWithMockDiscovery(t *testing.T) { - // Start a real node A (acts as the observing node) - const addrA = "127.0.0.1:18281" - hostA := "nodeA-md" - - poolA := NewGrainLocalPool(128, time.Minute, spawn) - - // Mock discovery starts with one bogus host that will fail to connect. - md := NewMockDiscovery([]string{"bogus-host-1"}) - syncedA, err := NewSyncedPool(poolA, hostA, md) - if err != nil { - t.Fatalf("NewSyncedPool error: %v", err) - } - - grpcSrvA, err := StartGRPCServer(addrA, poolA, syncedA) - if err != nil { - t.Fatalf("StartGRPCServer A error: %v", err) - } - defer grpcSrvA.GracefulStop() - - // Kick off watch processing by starting Watch() (NewSyncedPool does this internally - // when discovery is non-nil, but we ensure events channel is active). - // The initial bogus host should trigger AddRemote -> dial failure. - time.Sleep(300 * time.Millisecond) - - syncedA.mu.RLock() - if len(syncedA.remoteHosts) != 0 { - syncedA.mu.RUnlock() - t.Fatalf("expected 0 remoteHosts after failing dial, got %d", len(syncedA.remoteHosts)) - } - syncedA.mu.RUnlock() - - // Remove the bogus host (should not panic; no entry to clean up). - md.RemoveHost("bogus-host-1") - time.Sleep(100 * time.Millisecond) - - // Add another bogus host to ensure watcher still alive. - md.AddHost("bogus-host-2") - time.Sleep(300 * time.Millisecond) - - syncedA.mu.RLock() - if len(syncedA.remoteHosts) != 0 { - syncedA.mu.RUnlock() - t.Fatalf("expected 0 remoteHosts after second failing dial, got %d", len(syncedA.remoteHosts)) - } - syncedA.mu.RUnlock() - - // Clean up discovery - md.Close() -} diff --git a/proto/cart_actor.pb.go b/proto/cart_actor.pb.go deleted file mode 100644 index 6392815..0000000 --- a/proto/cart_actor.pb.go +++ /dev/null @@ -1,1545 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.36.10 -// protoc v3.21.12 -// source: cart_actor.proto - -package messages - -import ( - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - reflect "reflect" - sync "sync" - unsafe "unsafe" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -// Shared reply for all mutation RPCs. -type CartMutationReply struct { - state protoimpl.MessageState `protogen:"open.v1"` - StatusCode int32 `protobuf:"varint,1,opt,name=status_code,json=statusCode,proto3" json:"status_code,omitempty"` // HTTP-like status (200 success, 4xx client, 5xx server) - // Types that are valid to be assigned to Result: - // - // *CartMutationReply_State - // *CartMutationReply_Error - Result isCartMutationReply_Result `protobuf_oneof:"result"` - ServerTimestamp int64 `protobuf:"varint,4,opt,name=server_timestamp,json=serverTimestamp,proto3" json:"server_timestamp,omitempty"` // Server-assigned Unix timestamp (optional auditing) - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *CartMutationReply) Reset() { - *x = CartMutationReply{} - mi := &file_cart_actor_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *CartMutationReply) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*CartMutationReply) ProtoMessage() {} - -func (x *CartMutationReply) ProtoReflect() protoreflect.Message { - mi := &file_cart_actor_proto_msgTypes[0] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use CartMutationReply.ProtoReflect.Descriptor instead. -func (*CartMutationReply) Descriptor() ([]byte, []int) { - return file_cart_actor_proto_rawDescGZIP(), []int{0} -} - -func (x *CartMutationReply) GetStatusCode() int32 { - if x != nil { - return x.StatusCode - } - return 0 -} - -func (x *CartMutationReply) GetResult() isCartMutationReply_Result { - if x != nil { - return x.Result - } - return nil -} - -func (x *CartMutationReply) GetState() *CartState { - if x != nil { - if x, ok := x.Result.(*CartMutationReply_State); ok { - return x.State - } - } - return nil -} - -func (x *CartMutationReply) GetError() string { - if x != nil { - if x, ok := x.Result.(*CartMutationReply_Error); ok { - return x.Error - } - } - return "" -} - -func (x *CartMutationReply) GetServerTimestamp() int64 { - if x != nil { - return x.ServerTimestamp - } - return 0 -} - -type isCartMutationReply_Result interface { - isCartMutationReply_Result() -} - -type CartMutationReply_State struct { - State *CartState `protobuf:"bytes,2,opt,name=state,proto3,oneof"` // Updated cart state on success -} - -type CartMutationReply_Error struct { - Error string `protobuf:"bytes,3,opt,name=error,proto3,oneof"` // Error message on failure -} - -func (*CartMutationReply_State) isCartMutationReply_Result() {} - -func (*CartMutationReply_Error) isCartMutationReply_Result() {} - -// Fetch current cart state without mutation. -type StateRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - CartId string `protobuf:"bytes,1,opt,name=cart_id,json=cartId,proto3" json:"cart_id,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *StateRequest) Reset() { - *x = StateRequest{} - mi := &file_cart_actor_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *StateRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*StateRequest) ProtoMessage() {} - -func (x *StateRequest) ProtoReflect() protoreflect.Message { - mi := &file_cart_actor_proto_msgTypes[1] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use StateRequest.ProtoReflect.Descriptor instead. -func (*StateRequest) Descriptor() ([]byte, []int) { - return file_cart_actor_proto_rawDescGZIP(), []int{1} -} - -func (x *StateRequest) GetCartId() string { - if x != nil { - return x.CartId - } - return "" -} - -type StateReply struct { - state protoimpl.MessageState `protogen:"open.v1"` - StatusCode int32 `protobuf:"varint,1,opt,name=status_code,json=statusCode,proto3" json:"status_code,omitempty"` - // Types that are valid to be assigned to Result: - // - // *StateReply_State - // *StateReply_Error - Result isStateReply_Result `protobuf_oneof:"result"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *StateReply) Reset() { - *x = StateReply{} - mi := &file_cart_actor_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *StateReply) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*StateReply) ProtoMessage() {} - -func (x *StateReply) ProtoReflect() protoreflect.Message { - mi := &file_cart_actor_proto_msgTypes[2] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use StateReply.ProtoReflect.Descriptor instead. -func (*StateReply) Descriptor() ([]byte, []int) { - return file_cart_actor_proto_rawDescGZIP(), []int{2} -} - -func (x *StateReply) GetStatusCode() int32 { - if x != nil { - return x.StatusCode - } - return 0 -} - -func (x *StateReply) GetResult() isStateReply_Result { - if x != nil { - return x.Result - } - return nil -} - -func (x *StateReply) GetState() *CartState { - if x != nil { - if x, ok := x.Result.(*StateReply_State); ok { - return x.State - } - } - return nil -} - -func (x *StateReply) GetError() string { - if x != nil { - if x, ok := x.Result.(*StateReply_Error); ok { - return x.Error - } - } - return "" -} - -type isStateReply_Result interface { - isStateReply_Result() -} - -type StateReply_State struct { - State *CartState `protobuf:"bytes,2,opt,name=state,proto3,oneof"` -} - -type StateReply_Error struct { - Error string `protobuf:"bytes,3,opt,name=error,proto3,oneof"` -} - -func (*StateReply_State) isStateReply_Result() {} - -func (*StateReply_Error) isStateReply_Result() {} - -type AddRequestRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - CartId string `protobuf:"bytes,1,opt,name=cart_id,json=cartId,proto3" json:"cart_id,omitempty"` - ClientTimestamp int64 `protobuf:"varint,2,opt,name=client_timestamp,json=clientTimestamp,proto3" json:"client_timestamp,omitempty"` - Payload *AddRequest `protobuf:"bytes,10,opt,name=payload,proto3" json:"payload,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *AddRequestRequest) Reset() { - *x = AddRequestRequest{} - mi := &file_cart_actor_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *AddRequestRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*AddRequestRequest) ProtoMessage() {} - -func (x *AddRequestRequest) ProtoReflect() protoreflect.Message { - mi := &file_cart_actor_proto_msgTypes[3] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use AddRequestRequest.ProtoReflect.Descriptor instead. -func (*AddRequestRequest) Descriptor() ([]byte, []int) { - return file_cart_actor_proto_rawDescGZIP(), []int{3} -} - -func (x *AddRequestRequest) GetCartId() string { - if x != nil { - return x.CartId - } - return "" -} - -func (x *AddRequestRequest) GetClientTimestamp() int64 { - if x != nil { - return x.ClientTimestamp - } - return 0 -} - -func (x *AddRequestRequest) GetPayload() *AddRequest { - if x != nil { - return x.Payload - } - return nil -} - -type AddItemRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - CartId string `protobuf:"bytes,1,opt,name=cart_id,json=cartId,proto3" json:"cart_id,omitempty"` - ClientTimestamp int64 `protobuf:"varint,2,opt,name=client_timestamp,json=clientTimestamp,proto3" json:"client_timestamp,omitempty"` - Payload *AddItem `protobuf:"bytes,10,opt,name=payload,proto3" json:"payload,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *AddItemRequest) Reset() { - *x = AddItemRequest{} - mi := &file_cart_actor_proto_msgTypes[4] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *AddItemRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*AddItemRequest) ProtoMessage() {} - -func (x *AddItemRequest) ProtoReflect() protoreflect.Message { - mi := &file_cart_actor_proto_msgTypes[4] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use AddItemRequest.ProtoReflect.Descriptor instead. -func (*AddItemRequest) Descriptor() ([]byte, []int) { - return file_cart_actor_proto_rawDescGZIP(), []int{4} -} - -func (x *AddItemRequest) GetCartId() string { - if x != nil { - return x.CartId - } - return "" -} - -func (x *AddItemRequest) GetClientTimestamp() int64 { - if x != nil { - return x.ClientTimestamp - } - return 0 -} - -func (x *AddItemRequest) GetPayload() *AddItem { - if x != nil { - return x.Payload - } - return nil -} - -type RemoveItemRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - CartId string `protobuf:"bytes,1,opt,name=cart_id,json=cartId,proto3" json:"cart_id,omitempty"` - ClientTimestamp int64 `protobuf:"varint,2,opt,name=client_timestamp,json=clientTimestamp,proto3" json:"client_timestamp,omitempty"` - Payload *RemoveItem `protobuf:"bytes,10,opt,name=payload,proto3" json:"payload,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *RemoveItemRequest) Reset() { - *x = RemoveItemRequest{} - mi := &file_cart_actor_proto_msgTypes[5] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *RemoveItemRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*RemoveItemRequest) ProtoMessage() {} - -func (x *RemoveItemRequest) ProtoReflect() protoreflect.Message { - mi := &file_cart_actor_proto_msgTypes[5] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use RemoveItemRequest.ProtoReflect.Descriptor instead. -func (*RemoveItemRequest) Descriptor() ([]byte, []int) { - return file_cart_actor_proto_rawDescGZIP(), []int{5} -} - -func (x *RemoveItemRequest) GetCartId() string { - if x != nil { - return x.CartId - } - return "" -} - -func (x *RemoveItemRequest) GetClientTimestamp() int64 { - if x != nil { - return x.ClientTimestamp - } - return 0 -} - -func (x *RemoveItemRequest) GetPayload() *RemoveItem { - if x != nil { - return x.Payload - } - return nil -} - -type RemoveDeliveryRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - CartId string `protobuf:"bytes,1,opt,name=cart_id,json=cartId,proto3" json:"cart_id,omitempty"` - ClientTimestamp int64 `protobuf:"varint,2,opt,name=client_timestamp,json=clientTimestamp,proto3" json:"client_timestamp,omitempty"` - Payload *RemoveDelivery `protobuf:"bytes,10,opt,name=payload,proto3" json:"payload,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *RemoveDeliveryRequest) Reset() { - *x = RemoveDeliveryRequest{} - mi := &file_cart_actor_proto_msgTypes[6] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *RemoveDeliveryRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*RemoveDeliveryRequest) ProtoMessage() {} - -func (x *RemoveDeliveryRequest) ProtoReflect() protoreflect.Message { - mi := &file_cart_actor_proto_msgTypes[6] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use RemoveDeliveryRequest.ProtoReflect.Descriptor instead. -func (*RemoveDeliveryRequest) Descriptor() ([]byte, []int) { - return file_cart_actor_proto_rawDescGZIP(), []int{6} -} - -func (x *RemoveDeliveryRequest) GetCartId() string { - if x != nil { - return x.CartId - } - return "" -} - -func (x *RemoveDeliveryRequest) GetClientTimestamp() int64 { - if x != nil { - return x.ClientTimestamp - } - return 0 -} - -func (x *RemoveDeliveryRequest) GetPayload() *RemoveDelivery { - if x != nil { - return x.Payload - } - return nil -} - -type ChangeQuantityRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - CartId string `protobuf:"bytes,1,opt,name=cart_id,json=cartId,proto3" json:"cart_id,omitempty"` - ClientTimestamp int64 `protobuf:"varint,2,opt,name=client_timestamp,json=clientTimestamp,proto3" json:"client_timestamp,omitempty"` - Payload *ChangeQuantity `protobuf:"bytes,10,opt,name=payload,proto3" json:"payload,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *ChangeQuantityRequest) Reset() { - *x = ChangeQuantityRequest{} - mi := &file_cart_actor_proto_msgTypes[7] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *ChangeQuantityRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ChangeQuantityRequest) ProtoMessage() {} - -func (x *ChangeQuantityRequest) ProtoReflect() protoreflect.Message { - mi := &file_cart_actor_proto_msgTypes[7] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ChangeQuantityRequest.ProtoReflect.Descriptor instead. -func (*ChangeQuantityRequest) Descriptor() ([]byte, []int) { - return file_cart_actor_proto_rawDescGZIP(), []int{7} -} - -func (x *ChangeQuantityRequest) GetCartId() string { - if x != nil { - return x.CartId - } - return "" -} - -func (x *ChangeQuantityRequest) GetClientTimestamp() int64 { - if x != nil { - return x.ClientTimestamp - } - return 0 -} - -func (x *ChangeQuantityRequest) GetPayload() *ChangeQuantity { - if x != nil { - return x.Payload - } - return nil -} - -type SetDeliveryRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - CartId string `protobuf:"bytes,1,opt,name=cart_id,json=cartId,proto3" json:"cart_id,omitempty"` - ClientTimestamp int64 `protobuf:"varint,2,opt,name=client_timestamp,json=clientTimestamp,proto3" json:"client_timestamp,omitempty"` - Payload *SetDelivery `protobuf:"bytes,10,opt,name=payload,proto3" json:"payload,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *SetDeliveryRequest) Reset() { - *x = SetDeliveryRequest{} - mi := &file_cart_actor_proto_msgTypes[8] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *SetDeliveryRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*SetDeliveryRequest) ProtoMessage() {} - -func (x *SetDeliveryRequest) ProtoReflect() protoreflect.Message { - mi := &file_cart_actor_proto_msgTypes[8] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use SetDeliveryRequest.ProtoReflect.Descriptor instead. -func (*SetDeliveryRequest) Descriptor() ([]byte, []int) { - return file_cart_actor_proto_rawDescGZIP(), []int{8} -} - -func (x *SetDeliveryRequest) GetCartId() string { - if x != nil { - return x.CartId - } - return "" -} - -func (x *SetDeliveryRequest) GetClientTimestamp() int64 { - if x != nil { - return x.ClientTimestamp - } - return 0 -} - -func (x *SetDeliveryRequest) GetPayload() *SetDelivery { - if x != nil { - return x.Payload - } - return nil -} - -type SetPickupPointRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - CartId string `protobuf:"bytes,1,opt,name=cart_id,json=cartId,proto3" json:"cart_id,omitempty"` - ClientTimestamp int64 `protobuf:"varint,2,opt,name=client_timestamp,json=clientTimestamp,proto3" json:"client_timestamp,omitempty"` - Payload *SetPickupPoint `protobuf:"bytes,10,opt,name=payload,proto3" json:"payload,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *SetPickupPointRequest) Reset() { - *x = SetPickupPointRequest{} - mi := &file_cart_actor_proto_msgTypes[9] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *SetPickupPointRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*SetPickupPointRequest) ProtoMessage() {} - -func (x *SetPickupPointRequest) ProtoReflect() protoreflect.Message { - mi := &file_cart_actor_proto_msgTypes[9] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use SetPickupPointRequest.ProtoReflect.Descriptor instead. -func (*SetPickupPointRequest) Descriptor() ([]byte, []int) { - return file_cart_actor_proto_rawDescGZIP(), []int{9} -} - -func (x *SetPickupPointRequest) GetCartId() string { - if x != nil { - return x.CartId - } - return "" -} - -func (x *SetPickupPointRequest) GetClientTimestamp() int64 { - if x != nil { - return x.ClientTimestamp - } - return 0 -} - -func (x *SetPickupPointRequest) GetPayload() *SetPickupPoint { - if x != nil { - return x.Payload - } - return nil -} - -type CreateCheckoutOrderRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - CartId string `protobuf:"bytes,1,opt,name=cart_id,json=cartId,proto3" json:"cart_id,omitempty"` - ClientTimestamp int64 `protobuf:"varint,2,opt,name=client_timestamp,json=clientTimestamp,proto3" json:"client_timestamp,omitempty"` - Payload *CreateCheckoutOrder `protobuf:"bytes,10,opt,name=payload,proto3" json:"payload,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *CreateCheckoutOrderRequest) Reset() { - *x = CreateCheckoutOrderRequest{} - mi := &file_cart_actor_proto_msgTypes[10] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *CreateCheckoutOrderRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*CreateCheckoutOrderRequest) ProtoMessage() {} - -func (x *CreateCheckoutOrderRequest) ProtoReflect() protoreflect.Message { - mi := &file_cart_actor_proto_msgTypes[10] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use CreateCheckoutOrderRequest.ProtoReflect.Descriptor instead. -func (*CreateCheckoutOrderRequest) Descriptor() ([]byte, []int) { - return file_cart_actor_proto_rawDescGZIP(), []int{10} -} - -func (x *CreateCheckoutOrderRequest) GetCartId() string { - if x != nil { - return x.CartId - } - return "" -} - -func (x *CreateCheckoutOrderRequest) GetClientTimestamp() int64 { - if x != nil { - return x.ClientTimestamp - } - return 0 -} - -func (x *CreateCheckoutOrderRequest) GetPayload() *CreateCheckoutOrder { - if x != nil { - return x.Payload - } - return nil -} - -type SetCartItemsRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - CartId string `protobuf:"bytes,1,opt,name=cart_id,json=cartId,proto3" json:"cart_id,omitempty"` - ClientTimestamp int64 `protobuf:"varint,2,opt,name=client_timestamp,json=clientTimestamp,proto3" json:"client_timestamp,omitempty"` - Payload *SetCartRequest `protobuf:"bytes,10,opt,name=payload,proto3" json:"payload,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *SetCartItemsRequest) Reset() { - *x = SetCartItemsRequest{} - mi := &file_cart_actor_proto_msgTypes[11] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *SetCartItemsRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*SetCartItemsRequest) ProtoMessage() {} - -func (x *SetCartItemsRequest) ProtoReflect() protoreflect.Message { - mi := &file_cart_actor_proto_msgTypes[11] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use SetCartItemsRequest.ProtoReflect.Descriptor instead. -func (*SetCartItemsRequest) Descriptor() ([]byte, []int) { - return file_cart_actor_proto_rawDescGZIP(), []int{11} -} - -func (x *SetCartItemsRequest) GetCartId() string { - if x != nil { - return x.CartId - } - return "" -} - -func (x *SetCartItemsRequest) GetClientTimestamp() int64 { - if x != nil { - return x.ClientTimestamp - } - return 0 -} - -func (x *SetCartItemsRequest) GetPayload() *SetCartRequest { - if x != nil { - return x.Payload - } - return nil -} - -type OrderCompletedRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - CartId string `protobuf:"bytes,1,opt,name=cart_id,json=cartId,proto3" json:"cart_id,omitempty"` - ClientTimestamp int64 `protobuf:"varint,2,opt,name=client_timestamp,json=clientTimestamp,proto3" json:"client_timestamp,omitempty"` - Payload *OrderCreated `protobuf:"bytes,10,opt,name=payload,proto3" json:"payload,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *OrderCompletedRequest) Reset() { - *x = OrderCompletedRequest{} - mi := &file_cart_actor_proto_msgTypes[12] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *OrderCompletedRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*OrderCompletedRequest) ProtoMessage() {} - -func (x *OrderCompletedRequest) ProtoReflect() protoreflect.Message { - mi := &file_cart_actor_proto_msgTypes[12] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use OrderCompletedRequest.ProtoReflect.Descriptor instead. -func (*OrderCompletedRequest) Descriptor() ([]byte, []int) { - return file_cart_actor_proto_rawDescGZIP(), []int{12} -} - -func (x *OrderCompletedRequest) GetCartId() string { - if x != nil { - return x.CartId - } - return "" -} - -func (x *OrderCompletedRequest) GetClientTimestamp() int64 { - if x != nil { - return x.ClientTimestamp - } - return 0 -} - -func (x *OrderCompletedRequest) GetPayload() *OrderCreated { - if x != nil { - return x.Payload - } - return nil -} - -// Excerpt: updated messages for camelCase JSON output -type CartState struct { - state protoimpl.MessageState `protogen:"open.v1"` - Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` // was cart_id - Items []*CartItemState `protobuf:"bytes,2,rep,name=items,proto3" json:"items,omitempty"` - TotalPrice int64 `protobuf:"varint,3,opt,name=totalPrice,proto3" json:"totalPrice,omitempty"` // was total_price - TotalTax int64 `protobuf:"varint,4,opt,name=totalTax,proto3" json:"totalTax,omitempty"` // was total_tax - TotalDiscount int64 `protobuf:"varint,5,opt,name=totalDiscount,proto3" json:"totalDiscount,omitempty"` // was total_discount - Deliveries []*DeliveryState `protobuf:"bytes,6,rep,name=deliveries,proto3" json:"deliveries,omitempty"` - PaymentInProgress bool `protobuf:"varint,7,opt,name=paymentInProgress,proto3" json:"paymentInProgress,omitempty"` // was payment_in_progress - OrderReference string `protobuf:"bytes,8,opt,name=orderReference,proto3" json:"orderReference,omitempty"` // was order_reference - PaymentStatus string `protobuf:"bytes,9,opt,name=paymentStatus,proto3" json:"paymentStatus,omitempty"` // was payment_status - Processing bool `protobuf:"varint,10,opt,name=processing,proto3" json:"processing,omitempty"` // NEW (mirrors legacy CartGrain.processing) - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *CartState) Reset() { - *x = CartState{} - mi := &file_cart_actor_proto_msgTypes[13] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *CartState) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*CartState) ProtoMessage() {} - -func (x *CartState) ProtoReflect() protoreflect.Message { - mi := &file_cart_actor_proto_msgTypes[13] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use CartState.ProtoReflect.Descriptor instead. -func (*CartState) Descriptor() ([]byte, []int) { - return file_cart_actor_proto_rawDescGZIP(), []int{13} -} - -func (x *CartState) GetId() string { - if x != nil { - return x.Id - } - return "" -} - -func (x *CartState) GetItems() []*CartItemState { - if x != nil { - return x.Items - } - return nil -} - -func (x *CartState) GetTotalPrice() int64 { - if x != nil { - return x.TotalPrice - } - return 0 -} - -func (x *CartState) GetTotalTax() int64 { - if x != nil { - return x.TotalTax - } - return 0 -} - -func (x *CartState) GetTotalDiscount() int64 { - if x != nil { - return x.TotalDiscount - } - return 0 -} - -func (x *CartState) GetDeliveries() []*DeliveryState { - if x != nil { - return x.Deliveries - } - return nil -} - -func (x *CartState) GetPaymentInProgress() bool { - if x != nil { - return x.PaymentInProgress - } - return false -} - -func (x *CartState) GetOrderReference() string { - if x != nil { - return x.OrderReference - } - return "" -} - -func (x *CartState) GetPaymentStatus() string { - if x != nil { - return x.PaymentStatus - } - return "" -} - -func (x *CartState) GetProcessing() bool { - if x != nil { - return x.Processing - } - return false -} - -type CartItemState struct { - state protoimpl.MessageState `protogen:"open.v1"` - Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` - ItemId int64 `protobuf:"varint,2,opt,name=itemId,proto3" json:"itemId,omitempty"` // was source_item_id - Sku string `protobuf:"bytes,3,opt,name=sku,proto3" json:"sku,omitempty"` - Name string `protobuf:"bytes,4,opt,name=name,proto3" json:"name,omitempty"` - Price int64 `protobuf:"varint,5,opt,name=price,proto3" json:"price,omitempty"` // was unit_price - Qty int32 `protobuf:"varint,6,opt,name=qty,proto3" json:"qty,omitempty"` // was quantity - TotalPrice int64 `protobuf:"varint,7,opt,name=totalPrice,proto3" json:"totalPrice,omitempty"` // was total_price - TotalTax int64 `protobuf:"varint,8,opt,name=totalTax,proto3" json:"totalTax,omitempty"` // was total_tax - OrgPrice int64 `protobuf:"varint,9,opt,name=orgPrice,proto3" json:"orgPrice,omitempty"` // was org_price - TaxRate int32 `protobuf:"varint,10,opt,name=taxRate,proto3" json:"taxRate,omitempty"` // was tax_rate - TotalDiscount int64 `protobuf:"varint,11,opt,name=totalDiscount,proto3" json:"totalDiscount,omitempty"` - Brand string `protobuf:"bytes,12,opt,name=brand,proto3" json:"brand,omitempty"` - Category string `protobuf:"bytes,13,opt,name=category,proto3" json:"category,omitempty"` - Category2 string `protobuf:"bytes,14,opt,name=category2,proto3" json:"category2,omitempty"` - Category3 string `protobuf:"bytes,15,opt,name=category3,proto3" json:"category3,omitempty"` - Category4 string `protobuf:"bytes,16,opt,name=category4,proto3" json:"category4,omitempty"` - Category5 string `protobuf:"bytes,17,opt,name=category5,proto3" json:"category5,omitempty"` - Image string `protobuf:"bytes,18,opt,name=image,proto3" json:"image,omitempty"` - Type string `protobuf:"bytes,19,opt,name=type,proto3" json:"type,omitempty"` // was article_type - SellerId string `protobuf:"bytes,20,opt,name=sellerId,proto3" json:"sellerId,omitempty"` // was seller_id - SellerName string `protobuf:"bytes,21,opt,name=sellerName,proto3" json:"sellerName,omitempty"` // was seller_name - Disclaimer string `protobuf:"bytes,22,opt,name=disclaimer,proto3" json:"disclaimer,omitempty"` - Outlet string `protobuf:"bytes,23,opt,name=outlet,proto3" json:"outlet,omitempty"` - StoreId string `protobuf:"bytes,24,opt,name=storeId,proto3" json:"storeId,omitempty"` // was store_id - Stock int32 `protobuf:"varint,25,opt,name=stock,proto3" json:"stock,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *CartItemState) Reset() { - *x = CartItemState{} - mi := &file_cart_actor_proto_msgTypes[14] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *CartItemState) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*CartItemState) ProtoMessage() {} - -func (x *CartItemState) ProtoReflect() protoreflect.Message { - mi := &file_cart_actor_proto_msgTypes[14] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use CartItemState.ProtoReflect.Descriptor instead. -func (*CartItemState) Descriptor() ([]byte, []int) { - return file_cart_actor_proto_rawDescGZIP(), []int{14} -} - -func (x *CartItemState) GetId() int64 { - if x != nil { - return x.Id - } - return 0 -} - -func (x *CartItemState) GetItemId() int64 { - if x != nil { - return x.ItemId - } - return 0 -} - -func (x *CartItemState) GetSku() string { - if x != nil { - return x.Sku - } - return "" -} - -func (x *CartItemState) GetName() string { - if x != nil { - return x.Name - } - return "" -} - -func (x *CartItemState) GetPrice() int64 { - if x != nil { - return x.Price - } - return 0 -} - -func (x *CartItemState) GetQty() int32 { - if x != nil { - return x.Qty - } - return 0 -} - -func (x *CartItemState) GetTotalPrice() int64 { - if x != nil { - return x.TotalPrice - } - return 0 -} - -func (x *CartItemState) GetTotalTax() int64 { - if x != nil { - return x.TotalTax - } - return 0 -} - -func (x *CartItemState) GetOrgPrice() int64 { - if x != nil { - return x.OrgPrice - } - return 0 -} - -func (x *CartItemState) GetTaxRate() int32 { - if x != nil { - return x.TaxRate - } - return 0 -} - -func (x *CartItemState) GetTotalDiscount() int64 { - if x != nil { - return x.TotalDiscount - } - return 0 -} - -func (x *CartItemState) GetBrand() string { - if x != nil { - return x.Brand - } - return "" -} - -func (x *CartItemState) GetCategory() string { - if x != nil { - return x.Category - } - return "" -} - -func (x *CartItemState) GetCategory2() string { - if x != nil { - return x.Category2 - } - return "" -} - -func (x *CartItemState) GetCategory3() string { - if x != nil { - return x.Category3 - } - return "" -} - -func (x *CartItemState) GetCategory4() string { - if x != nil { - return x.Category4 - } - return "" -} - -func (x *CartItemState) GetCategory5() string { - if x != nil { - return x.Category5 - } - return "" -} - -func (x *CartItemState) GetImage() string { - if x != nil { - return x.Image - } - return "" -} - -func (x *CartItemState) GetType() string { - if x != nil { - return x.Type - } - return "" -} - -func (x *CartItemState) GetSellerId() string { - if x != nil { - return x.SellerId - } - return "" -} - -func (x *CartItemState) GetSellerName() string { - if x != nil { - return x.SellerName - } - return "" -} - -func (x *CartItemState) GetDisclaimer() string { - if x != nil { - return x.Disclaimer - } - return "" -} - -func (x *CartItemState) GetOutlet() string { - if x != nil { - return x.Outlet - } - return "" -} - -func (x *CartItemState) GetStoreId() string { - if x != nil { - return x.StoreId - } - return "" -} - -func (x *CartItemState) GetStock() int32 { - if x != nil { - return x.Stock - } - return 0 -} - -type DeliveryState struct { - state protoimpl.MessageState `protogen:"open.v1"` - Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` - Provider string `protobuf:"bytes,2,opt,name=provider,proto3" json:"provider,omitempty"` - Price int64 `protobuf:"varint,3,opt,name=price,proto3" json:"price,omitempty"` - Items []int64 `protobuf:"varint,4,rep,packed,name=items,proto3" json:"items,omitempty"` // was item_ids - PickupPoint *PickupPoint `protobuf:"bytes,5,opt,name=pickupPoint,proto3" json:"pickupPoint,omitempty"` // was pickup_point - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *DeliveryState) Reset() { - *x = DeliveryState{} - mi := &file_cart_actor_proto_msgTypes[15] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *DeliveryState) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*DeliveryState) ProtoMessage() {} - -func (x *DeliveryState) ProtoReflect() protoreflect.Message { - mi := &file_cart_actor_proto_msgTypes[15] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use DeliveryState.ProtoReflect.Descriptor instead. -func (*DeliveryState) Descriptor() ([]byte, []int) { - return file_cart_actor_proto_rawDescGZIP(), []int{15} -} - -func (x *DeliveryState) GetId() int64 { - if x != nil { - return x.Id - } - return 0 -} - -func (x *DeliveryState) GetProvider() string { - if x != nil { - return x.Provider - } - return "" -} - -func (x *DeliveryState) GetPrice() int64 { - if x != nil { - return x.Price - } - return 0 -} - -func (x *DeliveryState) GetItems() []int64 { - if x != nil { - return x.Items - } - return nil -} - -func (x *DeliveryState) GetPickupPoint() *PickupPoint { - if x != nil { - return x.PickupPoint - } - return nil -} - -var File_cart_actor_proto protoreflect.FileDescriptor - -const file_cart_actor_proto_rawDesc = "" + - "\n" + - "\x10cart_actor.proto\x12\bmessages\x1a\x0emessages.proto\"\xae\x01\n" + - "\x11CartMutationReply\x12\x1f\n" + - "\vstatus_code\x18\x01 \x01(\x05R\n" + - "statusCode\x12+\n" + - "\x05state\x18\x02 \x01(\v2\x13.messages.CartStateH\x00R\x05state\x12\x16\n" + - "\x05error\x18\x03 \x01(\tH\x00R\x05error\x12)\n" + - "\x10server_timestamp\x18\x04 \x01(\x03R\x0fserverTimestampB\b\n" + - "\x06result\"'\n" + - "\fStateRequest\x12\x17\n" + - "\acart_id\x18\x01 \x01(\tR\x06cartId\"|\n" + - "\n" + - "StateReply\x12\x1f\n" + - "\vstatus_code\x18\x01 \x01(\x05R\n" + - "statusCode\x12+\n" + - "\x05state\x18\x02 \x01(\v2\x13.messages.CartStateH\x00R\x05state\x12\x16\n" + - "\x05error\x18\x03 \x01(\tH\x00R\x05errorB\b\n" + - "\x06result\"\x87\x01\n" + - "\x11AddRequestRequest\x12\x17\n" + - "\acart_id\x18\x01 \x01(\tR\x06cartId\x12)\n" + - "\x10client_timestamp\x18\x02 \x01(\x03R\x0fclientTimestamp\x12.\n" + - "\apayload\x18\n" + - " \x01(\v2\x14.messages.AddRequestR\apayload\"\x81\x01\n" + - "\x0eAddItemRequest\x12\x17\n" + - "\acart_id\x18\x01 \x01(\tR\x06cartId\x12)\n" + - "\x10client_timestamp\x18\x02 \x01(\x03R\x0fclientTimestamp\x12+\n" + - "\apayload\x18\n" + - " \x01(\v2\x11.messages.AddItemR\apayload\"\x87\x01\n" + - "\x11RemoveItemRequest\x12\x17\n" + - "\acart_id\x18\x01 \x01(\tR\x06cartId\x12)\n" + - "\x10client_timestamp\x18\x02 \x01(\x03R\x0fclientTimestamp\x12.\n" + - "\apayload\x18\n" + - " \x01(\v2\x14.messages.RemoveItemR\apayload\"\x8f\x01\n" + - "\x15RemoveDeliveryRequest\x12\x17\n" + - "\acart_id\x18\x01 \x01(\tR\x06cartId\x12)\n" + - "\x10client_timestamp\x18\x02 \x01(\x03R\x0fclientTimestamp\x122\n" + - "\apayload\x18\n" + - " \x01(\v2\x18.messages.RemoveDeliveryR\apayload\"\x8f\x01\n" + - "\x15ChangeQuantityRequest\x12\x17\n" + - "\acart_id\x18\x01 \x01(\tR\x06cartId\x12)\n" + - "\x10client_timestamp\x18\x02 \x01(\x03R\x0fclientTimestamp\x122\n" + - "\apayload\x18\n" + - " \x01(\v2\x18.messages.ChangeQuantityR\apayload\"\x89\x01\n" + - "\x12SetDeliveryRequest\x12\x17\n" + - "\acart_id\x18\x01 \x01(\tR\x06cartId\x12)\n" + - "\x10client_timestamp\x18\x02 \x01(\x03R\x0fclientTimestamp\x12/\n" + - "\apayload\x18\n" + - " \x01(\v2\x15.messages.SetDeliveryR\apayload\"\x8f\x01\n" + - "\x15SetPickupPointRequest\x12\x17\n" + - "\acart_id\x18\x01 \x01(\tR\x06cartId\x12)\n" + - "\x10client_timestamp\x18\x02 \x01(\x03R\x0fclientTimestamp\x122\n" + - "\apayload\x18\n" + - " \x01(\v2\x18.messages.SetPickupPointR\apayload\"\x99\x01\n" + - "\x1aCreateCheckoutOrderRequest\x12\x17\n" + - "\acart_id\x18\x01 \x01(\tR\x06cartId\x12)\n" + - "\x10client_timestamp\x18\x02 \x01(\x03R\x0fclientTimestamp\x127\n" + - "\apayload\x18\n" + - " \x01(\v2\x1d.messages.CreateCheckoutOrderR\apayload\"\x8d\x01\n" + - "\x13SetCartItemsRequest\x12\x17\n" + - "\acart_id\x18\x01 \x01(\tR\x06cartId\x12)\n" + - "\x10client_timestamp\x18\x02 \x01(\x03R\x0fclientTimestamp\x122\n" + - "\apayload\x18\n" + - " \x01(\v2\x18.messages.SetCartRequestR\apayload\"\x8d\x01\n" + - "\x15OrderCompletedRequest\x12\x17\n" + - "\acart_id\x18\x01 \x01(\tR\x06cartId\x12)\n" + - "\x10client_timestamp\x18\x02 \x01(\x03R\x0fclientTimestamp\x120\n" + - "\apayload\x18\n" + - " \x01(\v2\x16.messages.OrderCreatedR\apayload\"\x81\x03\n" + - "\tCartState\x12\x0e\n" + - "\x02id\x18\x01 \x01(\tR\x02id\x12-\n" + - "\x05items\x18\x02 \x03(\v2\x17.messages.CartItemStateR\x05items\x12\x1e\n" + - "\n" + - "totalPrice\x18\x03 \x01(\x03R\n" + - "totalPrice\x12\x1a\n" + - "\btotalTax\x18\x04 \x01(\x03R\btotalTax\x12$\n" + - "\rtotalDiscount\x18\x05 \x01(\x03R\rtotalDiscount\x127\n" + - "\n" + - "deliveries\x18\x06 \x03(\v2\x17.messages.DeliveryStateR\n" + - "deliveries\x12,\n" + - "\x11paymentInProgress\x18\a \x01(\bR\x11paymentInProgress\x12&\n" + - "\x0eorderReference\x18\b \x01(\tR\x0eorderReference\x12$\n" + - "\rpaymentStatus\x18\t \x01(\tR\rpaymentStatus\x12\x1e\n" + - "\n" + - "processing\x18\n" + - " \x01(\bR\n" + - "processing\"\x95\x05\n" + - "\rCartItemState\x12\x0e\n" + - "\x02id\x18\x01 \x01(\x03R\x02id\x12\x16\n" + - "\x06itemId\x18\x02 \x01(\x03R\x06itemId\x12\x10\n" + - "\x03sku\x18\x03 \x01(\tR\x03sku\x12\x12\n" + - "\x04name\x18\x04 \x01(\tR\x04name\x12\x14\n" + - "\x05price\x18\x05 \x01(\x03R\x05price\x12\x10\n" + - "\x03qty\x18\x06 \x01(\x05R\x03qty\x12\x1e\n" + - "\n" + - "totalPrice\x18\a \x01(\x03R\n" + - "totalPrice\x12\x1a\n" + - "\btotalTax\x18\b \x01(\x03R\btotalTax\x12\x1a\n" + - "\borgPrice\x18\t \x01(\x03R\borgPrice\x12\x18\n" + - "\ataxRate\x18\n" + - " \x01(\x05R\ataxRate\x12$\n" + - "\rtotalDiscount\x18\v \x01(\x03R\rtotalDiscount\x12\x14\n" + - "\x05brand\x18\f \x01(\tR\x05brand\x12\x1a\n" + - "\bcategory\x18\r \x01(\tR\bcategory\x12\x1c\n" + - "\tcategory2\x18\x0e \x01(\tR\tcategory2\x12\x1c\n" + - "\tcategory3\x18\x0f \x01(\tR\tcategory3\x12\x1c\n" + - "\tcategory4\x18\x10 \x01(\tR\tcategory4\x12\x1c\n" + - "\tcategory5\x18\x11 \x01(\tR\tcategory5\x12\x14\n" + - "\x05image\x18\x12 \x01(\tR\x05image\x12\x12\n" + - "\x04type\x18\x13 \x01(\tR\x04type\x12\x1a\n" + - "\bsellerId\x18\x14 \x01(\tR\bsellerId\x12\x1e\n" + - "\n" + - "sellerName\x18\x15 \x01(\tR\n" + - "sellerName\x12\x1e\n" + - "\n" + - "disclaimer\x18\x16 \x01(\tR\n" + - "disclaimer\x12\x16\n" + - "\x06outlet\x18\x17 \x01(\tR\x06outlet\x12\x18\n" + - "\astoreId\x18\x18 \x01(\tR\astoreId\x12\x14\n" + - "\x05stock\x18\x19 \x01(\x05R\x05stock\"\xa0\x01\n" + - "\rDeliveryState\x12\x0e\n" + - "\x02id\x18\x01 \x01(\x03R\x02id\x12\x1a\n" + - "\bprovider\x18\x02 \x01(\tR\bprovider\x12\x14\n" + - "\x05price\x18\x03 \x01(\x03R\x05price\x12\x14\n" + - "\x05items\x18\x04 \x03(\x03R\x05items\x127\n" + - "\vpickupPoint\x18\x05 \x01(\v2\x15.messages.PickupPointR\vpickupPoint2\xed\x05\n" + - "\tCartActor\x12F\n" + - "\n" + - "AddRequest\x12\x1b.messages.AddRequestRequest\x1a\x1b.messages.CartMutationReply\x12@\n" + - "\aAddItem\x12\x18.messages.AddItemRequest\x1a\x1b.messages.CartMutationReply\x12F\n" + - "\n" + - "RemoveItem\x12\x1b.messages.RemoveItemRequest\x1a\x1b.messages.CartMutationReply\x12N\n" + - "\x0eRemoveDelivery\x12\x1f.messages.RemoveDeliveryRequest\x1a\x1b.messages.CartMutationReply\x12N\n" + - "\x0eChangeQuantity\x12\x1f.messages.ChangeQuantityRequest\x1a\x1b.messages.CartMutationReply\x12H\n" + - "\vSetDelivery\x12\x1c.messages.SetDeliveryRequest\x1a\x1b.messages.CartMutationReply\x12N\n" + - "\x0eSetPickupPoint\x12\x1f.messages.SetPickupPointRequest\x1a\x1b.messages.CartMutationReply\x12J\n" + - "\fSetCartItems\x12\x1d.messages.SetCartItemsRequest\x1a\x1b.messages.CartMutationReply\x12N\n" + - "\x0eOrderCompleted\x12\x1f.messages.OrderCompletedRequest\x1a\x1b.messages.CartMutationReply\x128\n" + - "\bGetState\x12\x16.messages.StateRequest\x1a\x14.messages.StateReplyB.Z,git.tornberg.me/go-cart-actor/proto;messagesb\x06proto3" - -var ( - file_cart_actor_proto_rawDescOnce sync.Once - file_cart_actor_proto_rawDescData []byte -) - -func file_cart_actor_proto_rawDescGZIP() []byte { - file_cart_actor_proto_rawDescOnce.Do(func() { - file_cart_actor_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_cart_actor_proto_rawDesc), len(file_cart_actor_proto_rawDesc))) - }) - return file_cart_actor_proto_rawDescData -} - -var file_cart_actor_proto_msgTypes = make([]protoimpl.MessageInfo, 16) -var file_cart_actor_proto_goTypes = []any{ - (*CartMutationReply)(nil), // 0: messages.CartMutationReply - (*StateRequest)(nil), // 1: messages.StateRequest - (*StateReply)(nil), // 2: messages.StateReply - (*AddRequestRequest)(nil), // 3: messages.AddRequestRequest - (*AddItemRequest)(nil), // 4: messages.AddItemRequest - (*RemoveItemRequest)(nil), // 5: messages.RemoveItemRequest - (*RemoveDeliveryRequest)(nil), // 6: messages.RemoveDeliveryRequest - (*ChangeQuantityRequest)(nil), // 7: messages.ChangeQuantityRequest - (*SetDeliveryRequest)(nil), // 8: messages.SetDeliveryRequest - (*SetPickupPointRequest)(nil), // 9: messages.SetPickupPointRequest - (*CreateCheckoutOrderRequest)(nil), // 10: messages.CreateCheckoutOrderRequest - (*SetCartItemsRequest)(nil), // 11: messages.SetCartItemsRequest - (*OrderCompletedRequest)(nil), // 12: messages.OrderCompletedRequest - (*CartState)(nil), // 13: messages.CartState - (*CartItemState)(nil), // 14: messages.CartItemState - (*DeliveryState)(nil), // 15: messages.DeliveryState - (*AddRequest)(nil), // 16: messages.AddRequest - (*AddItem)(nil), // 17: messages.AddItem - (*RemoveItem)(nil), // 18: messages.RemoveItem - (*RemoveDelivery)(nil), // 19: messages.RemoveDelivery - (*ChangeQuantity)(nil), // 20: messages.ChangeQuantity - (*SetDelivery)(nil), // 21: messages.SetDelivery - (*SetPickupPoint)(nil), // 22: messages.SetPickupPoint - (*CreateCheckoutOrder)(nil), // 23: messages.CreateCheckoutOrder - (*SetCartRequest)(nil), // 24: messages.SetCartRequest - (*OrderCreated)(nil), // 25: messages.OrderCreated - (*PickupPoint)(nil), // 26: messages.PickupPoint -} -var file_cart_actor_proto_depIdxs = []int32{ - 13, // 0: messages.CartMutationReply.state:type_name -> messages.CartState - 13, // 1: messages.StateReply.state:type_name -> messages.CartState - 16, // 2: messages.AddRequestRequest.payload:type_name -> messages.AddRequest - 17, // 3: messages.AddItemRequest.payload:type_name -> messages.AddItem - 18, // 4: messages.RemoveItemRequest.payload:type_name -> messages.RemoveItem - 19, // 5: messages.RemoveDeliveryRequest.payload:type_name -> messages.RemoveDelivery - 20, // 6: messages.ChangeQuantityRequest.payload:type_name -> messages.ChangeQuantity - 21, // 7: messages.SetDeliveryRequest.payload:type_name -> messages.SetDelivery - 22, // 8: messages.SetPickupPointRequest.payload:type_name -> messages.SetPickupPoint - 23, // 9: messages.CreateCheckoutOrderRequest.payload:type_name -> messages.CreateCheckoutOrder - 24, // 10: messages.SetCartItemsRequest.payload:type_name -> messages.SetCartRequest - 25, // 11: messages.OrderCompletedRequest.payload:type_name -> messages.OrderCreated - 14, // 12: messages.CartState.items:type_name -> messages.CartItemState - 15, // 13: messages.CartState.deliveries:type_name -> messages.DeliveryState - 26, // 14: messages.DeliveryState.pickupPoint:type_name -> messages.PickupPoint - 3, // 15: messages.CartActor.AddRequest:input_type -> messages.AddRequestRequest - 4, // 16: messages.CartActor.AddItem:input_type -> messages.AddItemRequest - 5, // 17: messages.CartActor.RemoveItem:input_type -> messages.RemoveItemRequest - 6, // 18: messages.CartActor.RemoveDelivery:input_type -> messages.RemoveDeliveryRequest - 7, // 19: messages.CartActor.ChangeQuantity:input_type -> messages.ChangeQuantityRequest - 8, // 20: messages.CartActor.SetDelivery:input_type -> messages.SetDeliveryRequest - 9, // 21: messages.CartActor.SetPickupPoint:input_type -> messages.SetPickupPointRequest - 11, // 22: messages.CartActor.SetCartItems:input_type -> messages.SetCartItemsRequest - 12, // 23: messages.CartActor.OrderCompleted:input_type -> messages.OrderCompletedRequest - 1, // 24: messages.CartActor.GetState:input_type -> messages.StateRequest - 0, // 25: messages.CartActor.AddRequest:output_type -> messages.CartMutationReply - 0, // 26: messages.CartActor.AddItem:output_type -> messages.CartMutationReply - 0, // 27: messages.CartActor.RemoveItem:output_type -> messages.CartMutationReply - 0, // 28: messages.CartActor.RemoveDelivery:output_type -> messages.CartMutationReply - 0, // 29: messages.CartActor.ChangeQuantity:output_type -> messages.CartMutationReply - 0, // 30: messages.CartActor.SetDelivery:output_type -> messages.CartMutationReply - 0, // 31: messages.CartActor.SetPickupPoint:output_type -> messages.CartMutationReply - 0, // 32: messages.CartActor.SetCartItems:output_type -> messages.CartMutationReply - 0, // 33: messages.CartActor.OrderCompleted:output_type -> messages.CartMutationReply - 2, // 34: messages.CartActor.GetState:output_type -> messages.StateReply - 25, // [25:35] is the sub-list for method output_type - 15, // [15:25] is the sub-list for method input_type - 15, // [15:15] is the sub-list for extension type_name - 15, // [15:15] is the sub-list for extension extendee - 0, // [0:15] is the sub-list for field type_name -} - -func init() { file_cart_actor_proto_init() } -func file_cart_actor_proto_init() { - if File_cart_actor_proto != nil { - return - } - file_messages_proto_init() - file_cart_actor_proto_msgTypes[0].OneofWrappers = []any{ - (*CartMutationReply_State)(nil), - (*CartMutationReply_Error)(nil), - } - file_cart_actor_proto_msgTypes[2].OneofWrappers = []any{ - (*StateReply_State)(nil), - (*StateReply_Error)(nil), - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: unsafe.Slice(unsafe.StringData(file_cart_actor_proto_rawDesc), len(file_cart_actor_proto_rawDesc)), - NumEnums: 0, - NumMessages: 16, - NumExtensions: 0, - NumServices: 1, - }, - GoTypes: file_cart_actor_proto_goTypes, - DependencyIndexes: file_cart_actor_proto_depIdxs, - MessageInfos: file_cart_actor_proto_msgTypes, - }.Build() - File_cart_actor_proto = out.File - file_cart_actor_proto_goTypes = nil - file_cart_actor_proto_depIdxs = nil -} diff --git a/proto/cart_actor.proto b/proto/cart_actor.proto deleted file mode 100644 index cf7ce58..0000000 --- a/proto/cart_actor.proto +++ /dev/null @@ -1,187 +0,0 @@ -syntax = "proto3"; - -package messages; - -option go_package = "git.tornberg.me/go-cart-actor/proto;messages"; - -import "messages.proto"; - -// ----------------------------------------------------------------------------- -// Cart Actor gRPC API (Breaking v2 - Per-Mutation RPCs) -// ----------------------------------------------------------------------------- -// This version removes the previous MutationEnvelope + Mutate RPC. -// Each mutation now has its own request wrapper and dedicated RPC method -// providing simpler, type-focused client stubs and enabling per-mutation -// metrics, auth and rate limiting. -// -// Regenerate Go code after editing: -// protoc --go_out=. --go_opt=paths=source_relative \ -// --go-grpc_out=. --go-grpc_opt=paths=source_relative \ -// proto/cart_actor.proto proto/messages.proto -// -// Backward compatibility: This is a breaking change (old clients must update). -// ----------------------------------------------------------------------------- - -// Shared reply for all mutation RPCs. -message CartMutationReply { - int32 status_code = 1; // HTTP-like status (200 success, 4xx client, 5xx server) - oneof result { - CartState state = 2; // Updated cart state on success - string error = 3; // Error message on failure - } - int64 server_timestamp = 4; // Server-assigned Unix timestamp (optional auditing) -} - -// Fetch current cart state without mutation. -message StateRequest { - string cart_id = 1; -} - -message StateReply { - int32 status_code = 1; - oneof result { - CartState state = 2; - string error = 3; - } -} - -// Per-mutation request wrappers. We wrap the existing inner mutation -// messages (defined in messages.proto) to add cart_id + optional metadata -// without altering the inner message definitions. - -message AddRequestRequest { - string cart_id = 1; - int64 client_timestamp = 2; - AddRequest payload = 10; -} - -message AddItemRequest { - string cart_id = 1; - int64 client_timestamp = 2; - AddItem payload = 10; -} - -message RemoveItemRequest { - string cart_id = 1; - int64 client_timestamp = 2; - RemoveItem payload = 10; -} - -message RemoveDeliveryRequest { - string cart_id = 1; - int64 client_timestamp = 2; - RemoveDelivery payload = 10; -} - -message ChangeQuantityRequest { - string cart_id = 1; - int64 client_timestamp = 2; - ChangeQuantity payload = 10; -} - -message SetDeliveryRequest { - string cart_id = 1; - int64 client_timestamp = 2; - SetDelivery payload = 10; -} - -message SetPickupPointRequest { - string cart_id = 1; - int64 client_timestamp = 2; - SetPickupPoint payload = 10; -} - -message CreateCheckoutOrderRequest { - string cart_id = 1; - int64 client_timestamp = 2; - CreateCheckoutOrder payload = 10; -} - -message SetCartItemsRequest { - string cart_id = 1; - int64 client_timestamp = 2; - SetCartRequest payload = 10; -} - -message OrderCompletedRequest { - string cart_id = 1; - int64 client_timestamp = 2; - OrderCreated payload = 10; -} - -// Excerpt: updated messages for camelCase JSON output -message CartState { - string id = 1; // was cart_id - repeated CartItemState items = 2; - int64 totalPrice = 3; // was total_price - int64 totalTax = 4; // was total_tax - int64 totalDiscount = 5; // was total_discount - repeated DeliveryState deliveries = 6; - bool paymentInProgress = 7; // was payment_in_progress - string orderReference = 8; // was order_reference - string paymentStatus = 9; // was payment_status - bool processing = 10; // NEW (mirrors legacy CartGrain.processing) -} - -message CartItemState { - int64 id = 1; - int64 itemId = 2; // was source_item_id - string sku = 3; - string name = 4; - int64 price = 5; // was unit_price - int32 qty = 6; // was quantity - int64 totalPrice = 7; // was total_price - int64 totalTax = 8; // was total_tax - int64 orgPrice = 9; // was org_price - int32 taxRate = 10; // was tax_rate - int64 totalDiscount = 11; - string brand = 12; - string category = 13; - string category2 = 14; - string category3 = 15; - string category4 = 16; - string category5 = 17; - string image = 18; - string type = 19; // was article_type - string sellerId = 20; // was seller_id - string sellerName = 21; // was seller_name - string disclaimer = 22; - string outlet = 23; - string storeId = 24; // was store_id - int32 stock = 25; -} - -message DeliveryState { - int64 id = 1; - string provider = 2; - int64 price = 3; - repeated int64 items = 4; // was item_ids - PickupPoint pickupPoint = 5; // was pickup_point -} - -// (CheckoutRequest / CheckoutReply removed - checkout handled at HTTP layer) - -// ----------------------------------------------------------------------------- -// Service definition (per-mutation RPCs + checkout) -// ----------------------------------------------------------------------------- -service CartActor { - rpc AddRequest(AddRequestRequest) returns (CartMutationReply); - rpc AddItem(AddItemRequest) returns (CartMutationReply); - rpc RemoveItem(RemoveItemRequest) returns (CartMutationReply); - rpc RemoveDelivery(RemoveDeliveryRequest) returns (CartMutationReply); - rpc ChangeQuantity(ChangeQuantityRequest) returns (CartMutationReply); - rpc SetDelivery(SetDeliveryRequest) returns (CartMutationReply); - rpc SetPickupPoint(SetPickupPointRequest) returns (CartMutationReply); - // (Checkout RPC removed - handled externally) - rpc SetCartItems(SetCartItemsRequest) returns (CartMutationReply); - rpc OrderCompleted(OrderCompletedRequest) returns (CartMutationReply); - - rpc GetState(StateRequest) returns (StateReply); -} - -// ----------------------------------------------------------------------------- -// Future enhancements: -// * BatchMutate RPC (repeated heterogeneous mutations) -// * Streaming state updates (WatchState) -// * Versioning / optimistic concurrency control -// ----------------------------------------------------------------------------- diff --git a/proto/cart_actor_grpc.pb.go b/proto/cart_actor_grpc.pb.go deleted file mode 100644 index bd34ce3..0000000 --- a/proto/cart_actor_grpc.pb.go +++ /dev/null @@ -1,473 +0,0 @@ -// Code generated by protoc-gen-go-grpc. DO NOT EDIT. -// versions: -// - protoc-gen-go-grpc v1.5.1 -// - protoc v3.21.12 -// source: cart_actor.proto - -package messages - -import ( - context "context" - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" -) - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -// Requires gRPC-Go v1.64.0 or later. -const _ = grpc.SupportPackageIsVersion9 - -const ( - CartActor_AddRequest_FullMethodName = "/messages.CartActor/AddRequest" - CartActor_AddItem_FullMethodName = "/messages.CartActor/AddItem" - CartActor_RemoveItem_FullMethodName = "/messages.CartActor/RemoveItem" - CartActor_RemoveDelivery_FullMethodName = "/messages.CartActor/RemoveDelivery" - CartActor_ChangeQuantity_FullMethodName = "/messages.CartActor/ChangeQuantity" - CartActor_SetDelivery_FullMethodName = "/messages.CartActor/SetDelivery" - CartActor_SetPickupPoint_FullMethodName = "/messages.CartActor/SetPickupPoint" - CartActor_SetCartItems_FullMethodName = "/messages.CartActor/SetCartItems" - CartActor_OrderCompleted_FullMethodName = "/messages.CartActor/OrderCompleted" - CartActor_GetState_FullMethodName = "/messages.CartActor/GetState" -) - -// CartActorClient is the client API for CartActor service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. -// -// ----------------------------------------------------------------------------- -// Service definition (per-mutation RPCs + checkout) -// ----------------------------------------------------------------------------- -type CartActorClient interface { - AddRequest(ctx context.Context, in *AddRequestRequest, opts ...grpc.CallOption) (*CartMutationReply, error) - AddItem(ctx context.Context, in *AddItemRequest, opts ...grpc.CallOption) (*CartMutationReply, error) - RemoveItem(ctx context.Context, in *RemoveItemRequest, opts ...grpc.CallOption) (*CartMutationReply, error) - RemoveDelivery(ctx context.Context, in *RemoveDeliveryRequest, opts ...grpc.CallOption) (*CartMutationReply, error) - ChangeQuantity(ctx context.Context, in *ChangeQuantityRequest, opts ...grpc.CallOption) (*CartMutationReply, error) - SetDelivery(ctx context.Context, in *SetDeliveryRequest, opts ...grpc.CallOption) (*CartMutationReply, error) - SetPickupPoint(ctx context.Context, in *SetPickupPointRequest, opts ...grpc.CallOption) (*CartMutationReply, error) - // (Checkout RPC removed - handled externally) - SetCartItems(ctx context.Context, in *SetCartItemsRequest, opts ...grpc.CallOption) (*CartMutationReply, error) - OrderCompleted(ctx context.Context, in *OrderCompletedRequest, opts ...grpc.CallOption) (*CartMutationReply, error) - GetState(ctx context.Context, in *StateRequest, opts ...grpc.CallOption) (*StateReply, error) -} - -type cartActorClient struct { - cc grpc.ClientConnInterface -} - -func NewCartActorClient(cc grpc.ClientConnInterface) CartActorClient { - return &cartActorClient{cc} -} - -func (c *cartActorClient) AddRequest(ctx context.Context, in *AddRequestRequest, opts ...grpc.CallOption) (*CartMutationReply, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(CartMutationReply) - err := c.cc.Invoke(ctx, CartActor_AddRequest_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *cartActorClient) AddItem(ctx context.Context, in *AddItemRequest, opts ...grpc.CallOption) (*CartMutationReply, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(CartMutationReply) - err := c.cc.Invoke(ctx, CartActor_AddItem_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *cartActorClient) RemoveItem(ctx context.Context, in *RemoveItemRequest, opts ...grpc.CallOption) (*CartMutationReply, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(CartMutationReply) - err := c.cc.Invoke(ctx, CartActor_RemoveItem_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *cartActorClient) RemoveDelivery(ctx context.Context, in *RemoveDeliveryRequest, opts ...grpc.CallOption) (*CartMutationReply, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(CartMutationReply) - err := c.cc.Invoke(ctx, CartActor_RemoveDelivery_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *cartActorClient) ChangeQuantity(ctx context.Context, in *ChangeQuantityRequest, opts ...grpc.CallOption) (*CartMutationReply, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(CartMutationReply) - err := c.cc.Invoke(ctx, CartActor_ChangeQuantity_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *cartActorClient) SetDelivery(ctx context.Context, in *SetDeliveryRequest, opts ...grpc.CallOption) (*CartMutationReply, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(CartMutationReply) - err := c.cc.Invoke(ctx, CartActor_SetDelivery_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *cartActorClient) SetPickupPoint(ctx context.Context, in *SetPickupPointRequest, opts ...grpc.CallOption) (*CartMutationReply, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(CartMutationReply) - err := c.cc.Invoke(ctx, CartActor_SetPickupPoint_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *cartActorClient) SetCartItems(ctx context.Context, in *SetCartItemsRequest, opts ...grpc.CallOption) (*CartMutationReply, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(CartMutationReply) - err := c.cc.Invoke(ctx, CartActor_SetCartItems_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *cartActorClient) OrderCompleted(ctx context.Context, in *OrderCompletedRequest, opts ...grpc.CallOption) (*CartMutationReply, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(CartMutationReply) - err := c.cc.Invoke(ctx, CartActor_OrderCompleted_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *cartActorClient) GetState(ctx context.Context, in *StateRequest, opts ...grpc.CallOption) (*StateReply, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(StateReply) - err := c.cc.Invoke(ctx, CartActor_GetState_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -// CartActorServer is the server API for CartActor service. -// All implementations must embed UnimplementedCartActorServer -// for forward compatibility. -// -// ----------------------------------------------------------------------------- -// Service definition (per-mutation RPCs + checkout) -// ----------------------------------------------------------------------------- -type CartActorServer interface { - AddRequest(context.Context, *AddRequestRequest) (*CartMutationReply, error) - AddItem(context.Context, *AddItemRequest) (*CartMutationReply, error) - RemoveItem(context.Context, *RemoveItemRequest) (*CartMutationReply, error) - RemoveDelivery(context.Context, *RemoveDeliveryRequest) (*CartMutationReply, error) - ChangeQuantity(context.Context, *ChangeQuantityRequest) (*CartMutationReply, error) - SetDelivery(context.Context, *SetDeliveryRequest) (*CartMutationReply, error) - SetPickupPoint(context.Context, *SetPickupPointRequest) (*CartMutationReply, error) - // (Checkout RPC removed - handled externally) - SetCartItems(context.Context, *SetCartItemsRequest) (*CartMutationReply, error) - OrderCompleted(context.Context, *OrderCompletedRequest) (*CartMutationReply, error) - GetState(context.Context, *StateRequest) (*StateReply, error) - mustEmbedUnimplementedCartActorServer() -} - -// UnimplementedCartActorServer must be embedded to have -// forward compatible implementations. -// -// NOTE: this should be embedded by value instead of pointer to avoid a nil -// pointer dereference when methods are called. -type UnimplementedCartActorServer struct{} - -func (UnimplementedCartActorServer) AddRequest(context.Context, *AddRequestRequest) (*CartMutationReply, error) { - return nil, status.Errorf(codes.Unimplemented, "method AddRequest not implemented") -} -func (UnimplementedCartActorServer) AddItem(context.Context, *AddItemRequest) (*CartMutationReply, error) { - return nil, status.Errorf(codes.Unimplemented, "method AddItem not implemented") -} -func (UnimplementedCartActorServer) RemoveItem(context.Context, *RemoveItemRequest) (*CartMutationReply, error) { - return nil, status.Errorf(codes.Unimplemented, "method RemoveItem not implemented") -} -func (UnimplementedCartActorServer) RemoveDelivery(context.Context, *RemoveDeliveryRequest) (*CartMutationReply, error) { - return nil, status.Errorf(codes.Unimplemented, "method RemoveDelivery not implemented") -} -func (UnimplementedCartActorServer) ChangeQuantity(context.Context, *ChangeQuantityRequest) (*CartMutationReply, error) { - return nil, status.Errorf(codes.Unimplemented, "method ChangeQuantity not implemented") -} -func (UnimplementedCartActorServer) SetDelivery(context.Context, *SetDeliveryRequest) (*CartMutationReply, error) { - return nil, status.Errorf(codes.Unimplemented, "method SetDelivery not implemented") -} -func (UnimplementedCartActorServer) SetPickupPoint(context.Context, *SetPickupPointRequest) (*CartMutationReply, error) { - return nil, status.Errorf(codes.Unimplemented, "method SetPickupPoint not implemented") -} -func (UnimplementedCartActorServer) SetCartItems(context.Context, *SetCartItemsRequest) (*CartMutationReply, error) { - return nil, status.Errorf(codes.Unimplemented, "method SetCartItems not implemented") -} -func (UnimplementedCartActorServer) OrderCompleted(context.Context, *OrderCompletedRequest) (*CartMutationReply, error) { - return nil, status.Errorf(codes.Unimplemented, "method OrderCompleted not implemented") -} -func (UnimplementedCartActorServer) GetState(context.Context, *StateRequest) (*StateReply, error) { - return nil, status.Errorf(codes.Unimplemented, "method GetState not implemented") -} -func (UnimplementedCartActorServer) mustEmbedUnimplementedCartActorServer() {} -func (UnimplementedCartActorServer) testEmbeddedByValue() {} - -// UnsafeCartActorServer may be embedded to opt out of forward compatibility for this service. -// Use of this interface is not recommended, as added methods to CartActorServer will -// result in compilation errors. -type UnsafeCartActorServer interface { - mustEmbedUnimplementedCartActorServer() -} - -func RegisterCartActorServer(s grpc.ServiceRegistrar, srv CartActorServer) { - // If the following call pancis, it indicates UnimplementedCartActorServer was - // embedded by pointer and is nil. This will cause panics if an - // unimplemented method is ever invoked, so we test this at initialization - // time to prevent it from happening at runtime later due to I/O. - if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { - t.testEmbeddedByValue() - } - s.RegisterService(&CartActor_ServiceDesc, srv) -} - -func _CartActor_AddRequest_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(AddRequestRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(CartActorServer).AddRequest(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: CartActor_AddRequest_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(CartActorServer).AddRequest(ctx, req.(*AddRequestRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _CartActor_AddItem_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(AddItemRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(CartActorServer).AddItem(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: CartActor_AddItem_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(CartActorServer).AddItem(ctx, req.(*AddItemRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _CartActor_RemoveItem_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(RemoveItemRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(CartActorServer).RemoveItem(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: CartActor_RemoveItem_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(CartActorServer).RemoveItem(ctx, req.(*RemoveItemRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _CartActor_RemoveDelivery_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(RemoveDeliveryRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(CartActorServer).RemoveDelivery(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: CartActor_RemoveDelivery_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(CartActorServer).RemoveDelivery(ctx, req.(*RemoveDeliveryRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _CartActor_ChangeQuantity_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(ChangeQuantityRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(CartActorServer).ChangeQuantity(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: CartActor_ChangeQuantity_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(CartActorServer).ChangeQuantity(ctx, req.(*ChangeQuantityRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _CartActor_SetDelivery_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(SetDeliveryRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(CartActorServer).SetDelivery(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: CartActor_SetDelivery_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(CartActorServer).SetDelivery(ctx, req.(*SetDeliveryRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _CartActor_SetPickupPoint_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(SetPickupPointRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(CartActorServer).SetPickupPoint(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: CartActor_SetPickupPoint_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(CartActorServer).SetPickupPoint(ctx, req.(*SetPickupPointRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _CartActor_SetCartItems_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(SetCartItemsRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(CartActorServer).SetCartItems(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: CartActor_SetCartItems_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(CartActorServer).SetCartItems(ctx, req.(*SetCartItemsRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _CartActor_OrderCompleted_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(OrderCompletedRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(CartActorServer).OrderCompleted(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: CartActor_OrderCompleted_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(CartActorServer).OrderCompleted(ctx, req.(*OrderCompletedRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _CartActor_GetState_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(StateRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(CartActorServer).GetState(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: CartActor_GetState_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(CartActorServer).GetState(ctx, req.(*StateRequest)) - } - return interceptor(ctx, in, info, handler) -} - -// CartActor_ServiceDesc is the grpc.ServiceDesc for CartActor service. -// It's only intended for direct use with grpc.RegisterService, -// and not to be introspected or modified (even as a copy) -var CartActor_ServiceDesc = grpc.ServiceDesc{ - ServiceName: "messages.CartActor", - HandlerType: (*CartActorServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "AddRequest", - Handler: _CartActor_AddRequest_Handler, - }, - { - MethodName: "AddItem", - Handler: _CartActor_AddItem_Handler, - }, - { - MethodName: "RemoveItem", - Handler: _CartActor_RemoveItem_Handler, - }, - { - MethodName: "RemoveDelivery", - Handler: _CartActor_RemoveDelivery_Handler, - }, - { - MethodName: "ChangeQuantity", - Handler: _CartActor_ChangeQuantity_Handler, - }, - { - MethodName: "SetDelivery", - Handler: _CartActor_SetDelivery_Handler, - }, - { - MethodName: "SetPickupPoint", - Handler: _CartActor_SetPickupPoint_Handler, - }, - { - MethodName: "SetCartItems", - Handler: _CartActor_SetCartItems_Handler, - }, - { - MethodName: "OrderCompleted", - Handler: _CartActor_OrderCompleted_Handler, - }, - { - MethodName: "GetState", - Handler: _CartActor_GetState_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "cart_actor.proto", -} diff --git a/synced-pool.go b/synced-pool.go index d33cf12..abe2926 100644 --- a/synced-pool.go +++ b/synced-pool.go @@ -46,7 +46,6 @@ type SyncedPool struct { type RemoteHostGRPC struct { Host string Conn *grpc.ClientConn - CartClient proto.CartActorClient ControlClient proto.ControlPlaneClient MissedPings int } @@ -152,7 +151,6 @@ func (p *SyncedPool) AddRemote(host string) { return } - cartClient := proto.NewCartActorClient(conn) controlClient := proto.NewControlPlaneClient(conn) // Health check (Ping) with limited retries @@ -174,9 +172,9 @@ func (p *SyncedPool) AddRemote(host string) { } remote := &RemoteHostGRPC{ - Host: host, - Conn: conn, - CartClient: cartClient, + Host: host, + Conn: conn, + ControlClient: controlClient, MissedPings: 0, }