even more refactoring
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -3,66 +3,114 @@ syntax = "proto3";
|
||||
package messages;
|
||||
|
||||
option go_package = "git.tornberg.me/go-cart-actor/proto;messages";
|
||||
|
||||
import "messages.proto";
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Cart Actor gRPC API (oneof Envelope Variant)
|
||||
// Cart Actor gRPC API (Breaking v2 - Per-Mutation RPCs)
|
||||
// -----------------------------------------------------------------------------
|
||||
// This version removes the legacy numeric MutationType enum + raw bytes payload
|
||||
// approach and replaces it with a strongly typed oneof envelope. Each concrete
|
||||
// mutation proto is embedded directly, enabling:
|
||||
// * Type-safe routing server-side (simple type switch on the oneof).
|
||||
// * Direct persistence of MutationEnvelope messages (no custom binary header).
|
||||
// * Elimination of the legacy message handler registry.
|
||||
// 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.
|
||||
//
|
||||
// NOTE: Regenerate Go code after editing:
|
||||
// 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).
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
// MutationEnvelope carries exactly one mutation plus metadata.
|
||||
// client_timestamp:
|
||||
// - Optional Unix timestamp provided by the client.
|
||||
// - If zero the server MAY overwrite with its local time.
|
||||
message MutationEnvelope {
|
||||
string cart_id = 1;
|
||||
int64 client_timestamp = 2;
|
||||
|
||||
oneof mutation {
|
||||
AddRequest add_request = 10;
|
||||
AddItem add_item = 11;
|
||||
RemoveItem remove_item = 12;
|
||||
RemoveDelivery remove_delivery = 13;
|
||||
ChangeQuantity change_quantity = 14;
|
||||
SetDelivery set_delivery = 15;
|
||||
SetPickupPoint set_pickup_point = 16;
|
||||
CreateCheckoutOrder create_checkout_order = 17;
|
||||
SetCartRequest set_cart_items = 18;
|
||||
OrderCreated order_completed = 19;
|
||||
// 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)
|
||||
}
|
||||
|
||||
// MutationReply returns a legacy-style status code plus a JSON payload
|
||||
// holding either the updated cart state (on success) or an error string.
|
||||
message MutationReply {
|
||||
int32 status_code = 1;
|
||||
// Fetch current cart state without mutation.
|
||||
message StateRequest {
|
||||
string cart_id = 1;
|
||||
}
|
||||
|
||||
// Exactly one of state or error will be set.
|
||||
message StateReply {
|
||||
int32 status_code = 1;
|
||||
oneof result {
|
||||
CartState state = 2;
|
||||
string error = 3;
|
||||
}
|
||||
}
|
||||
|
||||
// StateRequest fetches current cart state without mutating.
|
||||
message StateRequest {
|
||||
// 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;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// CartState represents the full cart snapshot returned by state/mutation replies.
|
||||
// Replaces the previous raw JSON payload.
|
||||
// Cart state snapshot (unchanged from v1 except envelope removal context)
|
||||
// -----------------------------------------------------------------------------
|
||||
message CartState {
|
||||
string cart_id = 1;
|
||||
@@ -76,7 +124,6 @@ message CartState {
|
||||
string payment_status = 9;
|
||||
}
|
||||
|
||||
// Lightweight representation of an item in the cart
|
||||
message CartItemState {
|
||||
int64 id = 1;
|
||||
int64 source_item_id = 2;
|
||||
@@ -105,38 +152,37 @@ message CartItemState {
|
||||
int32 stock = 25;
|
||||
}
|
||||
|
||||
// Delivery / shipping entry
|
||||
message DeliveryState {
|
||||
int64 id = 1;
|
||||
string provider = 2;
|
||||
int64 price = 3;
|
||||
repeated int64 item_ids = 4;
|
||||
PickupPoint pickup_point = 5;
|
||||
PickupPoint pickup_point = 5; // Defined in messages.proto
|
||||
}
|
||||
|
||||
// StateReply mirrors MutationReply for consistency.
|
||||
message StateReply {
|
||||
int32 status_code = 1;
|
||||
// (CheckoutRequest / CheckoutReply removed - checkout handled at HTTP layer)
|
||||
|
||||
oneof result {
|
||||
CartState state = 2;
|
||||
string error = 3;
|
||||
}
|
||||
}
|
||||
|
||||
// CartActor exposes mutation and state retrieval for remote grains.
|
||||
// -----------------------------------------------------------------------------
|
||||
// Service definition (per-mutation RPCs + checkout)
|
||||
// -----------------------------------------------------------------------------
|
||||
service CartActor {
|
||||
// Mutate applies a single mutation to a cart, creating the cart lazily if needed.
|
||||
rpc Mutate(MutationEnvelope) returns (MutationReply);
|
||||
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);
|
||||
|
||||
// GetState retrieves the cart's current state (JSON).
|
||||
rpc GetState(StateRequest) returns (StateReply);
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Future Enhancements:
|
||||
// * Replace JSON state payload with a strongly typed CartState proto.
|
||||
// * Add streaming RPC (e.g., WatchState) for live updates.
|
||||
// * Add batch mutations (repeated MutationEnvelope) if performance requires.
|
||||
// * Introduce optimistic concurrency via version fields if external writers appear.
|
||||
// Future enhancements:
|
||||
// * BatchMutate RPC (repeated heterogeneous mutations)
|
||||
// * Streaming state updates (WatchState)
|
||||
// * Versioning / optimistic concurrency control
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
@@ -19,19 +19,36 @@ import (
|
||||
const _ = grpc.SupportPackageIsVersion9
|
||||
|
||||
const (
|
||||
CartActor_Mutate_FullMethodName = "/messages.CartActor/Mutate"
|
||||
CartActor_GetState_FullMethodName = "/messages.CartActor/GetState"
|
||||
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.
|
||||
//
|
||||
// CartActor exposes mutation and state retrieval for remote grains.
|
||||
// -----------------------------------------------------------------------------
|
||||
// Service definition (per-mutation RPCs + checkout)
|
||||
// -----------------------------------------------------------------------------
|
||||
type CartActorClient interface {
|
||||
// Mutate applies a single mutation to a cart, creating the cart lazily if needed.
|
||||
Mutate(ctx context.Context, in *MutationEnvelope, opts ...grpc.CallOption) (*MutationReply, error)
|
||||
// GetState retrieves the cart's current state (JSON).
|
||||
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)
|
||||
}
|
||||
|
||||
@@ -43,10 +60,90 @@ func NewCartActorClient(cc grpc.ClientConnInterface) CartActorClient {
|
||||
return &cartActorClient{cc}
|
||||
}
|
||||
|
||||
func (c *cartActorClient) Mutate(ctx context.Context, in *MutationEnvelope, opts ...grpc.CallOption) (*MutationReply, error) {
|
||||
func (c *cartActorClient) AddRequest(ctx context.Context, in *AddRequestRequest, opts ...grpc.CallOption) (*CartMutationReply, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(MutationReply)
|
||||
err := c.cc.Invoke(ctx, CartActor_Mutate_FullMethodName, in, out, cOpts...)
|
||||
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
|
||||
}
|
||||
@@ -67,11 +164,20 @@ func (c *cartActorClient) GetState(ctx context.Context, in *StateRequest, opts .
|
||||
// All implementations must embed UnimplementedCartActorServer
|
||||
// for forward compatibility.
|
||||
//
|
||||
// CartActor exposes mutation and state retrieval for remote grains.
|
||||
// -----------------------------------------------------------------------------
|
||||
// Service definition (per-mutation RPCs + checkout)
|
||||
// -----------------------------------------------------------------------------
|
||||
type CartActorServer interface {
|
||||
// Mutate applies a single mutation to a cart, creating the cart lazily if needed.
|
||||
Mutate(context.Context, *MutationEnvelope) (*MutationReply, error)
|
||||
// GetState retrieves the cart's current state (JSON).
|
||||
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()
|
||||
}
|
||||
@@ -83,8 +189,32 @@ type CartActorServer interface {
|
||||
// pointer dereference when methods are called.
|
||||
type UnimplementedCartActorServer struct{}
|
||||
|
||||
func (UnimplementedCartActorServer) Mutate(context.Context, *MutationEnvelope) (*MutationReply, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method Mutate not implemented")
|
||||
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")
|
||||
@@ -110,20 +240,164 @@ func RegisterCartActorServer(s grpc.ServiceRegistrar, srv CartActorServer) {
|
||||
s.RegisterService(&CartActor_ServiceDesc, srv)
|
||||
}
|
||||
|
||||
func _CartActor_Mutate_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(MutationEnvelope)
|
||||
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).Mutate(ctx, in)
|
||||
return srv.(CartActorServer).AddRequest(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: CartActor_Mutate_FullMethodName,
|
||||
FullMethod: CartActor_AddRequest_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(CartActorServer).Mutate(ctx, req.(*MutationEnvelope))
|
||||
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)
|
||||
}
|
||||
@@ -154,8 +428,40 @@ var CartActor_ServiceDesc = grpc.ServiceDesc{
|
||||
HandlerType: (*CartActorServer)(nil),
|
||||
Methods: []grpc.MethodDesc{
|
||||
{
|
||||
MethodName: "Mutate",
|
||||
Handler: _CartActor_Mutate_Handler,
|
||||
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",
|
||||
|
||||
@@ -889,6 +889,102 @@ func (x *OrderCreated) GetStatus() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
type Noop struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *Noop) Reset() {
|
||||
*x = Noop{}
|
||||
mi := &file_messages_proto_msgTypes[11]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *Noop) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*Noop) ProtoMessage() {}
|
||||
|
||||
func (x *Noop) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_messages_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 Noop.ProtoReflect.Descriptor instead.
|
||||
func (*Noop) Descriptor() ([]byte, []int) {
|
||||
return file_messages_proto_rawDescGZIP(), []int{11}
|
||||
}
|
||||
|
||||
type InitializeCheckout struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
OrderId string `protobuf:"bytes,1,opt,name=orderId,proto3" json:"orderId,omitempty"`
|
||||
Status string `protobuf:"bytes,2,opt,name=status,proto3" json:"status,omitempty"`
|
||||
PaymentInProgress bool `protobuf:"varint,3,opt,name=paymentInProgress,proto3" json:"paymentInProgress,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *InitializeCheckout) Reset() {
|
||||
*x = InitializeCheckout{}
|
||||
mi := &file_messages_proto_msgTypes[12]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *InitializeCheckout) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*InitializeCheckout) ProtoMessage() {}
|
||||
|
||||
func (x *InitializeCheckout) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_messages_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 InitializeCheckout.ProtoReflect.Descriptor instead.
|
||||
func (*InitializeCheckout) Descriptor() ([]byte, []int) {
|
||||
return file_messages_proto_rawDescGZIP(), []int{12}
|
||||
}
|
||||
|
||||
func (x *InitializeCheckout) GetOrderId() string {
|
||||
if x != nil {
|
||||
return x.OrderId
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *InitializeCheckout) GetStatus() string {
|
||||
if x != nil {
|
||||
return x.Status
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *InitializeCheckout) GetPaymentInProgress() bool {
|
||||
if x != nil {
|
||||
return x.PaymentInProgress
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
var File_messages_proto protoreflect.FileDescriptor
|
||||
|
||||
const file_messages_proto_rawDesc = "" +
|
||||
@@ -997,7 +1093,12 @@ const file_messages_proto_rawDesc = "" +
|
||||
"\acountry\x18\x06 \x01(\tR\acountry\"@\n" +
|
||||
"\fOrderCreated\x12\x18\n" +
|
||||
"\aorderId\x18\x01 \x01(\tR\aorderId\x12\x16\n" +
|
||||
"\x06status\x18\x02 \x01(\tR\x06statusB.Z,git.tornberg.me/go-cart-actor/proto;messagesb\x06proto3"
|
||||
"\x06status\x18\x02 \x01(\tR\x06status\"\x06\n" +
|
||||
"\x04Noop\"t\n" +
|
||||
"\x12InitializeCheckout\x12\x18\n" +
|
||||
"\aorderId\x18\x01 \x01(\tR\aorderId\x12\x16\n" +
|
||||
"\x06status\x18\x02 \x01(\tR\x06status\x12,\n" +
|
||||
"\x11paymentInProgress\x18\x03 \x01(\bR\x11paymentInProgressB.Z,git.tornberg.me/go-cart-actor/proto;messagesb\x06proto3"
|
||||
|
||||
var (
|
||||
file_messages_proto_rawDescOnce sync.Once
|
||||
@@ -1011,7 +1112,7 @@ func file_messages_proto_rawDescGZIP() []byte {
|
||||
return file_messages_proto_rawDescData
|
||||
}
|
||||
|
||||
var file_messages_proto_msgTypes = make([]protoimpl.MessageInfo, 11)
|
||||
var file_messages_proto_msgTypes = make([]protoimpl.MessageInfo, 13)
|
||||
var file_messages_proto_goTypes = []any{
|
||||
(*AddRequest)(nil), // 0: messages.AddRequest
|
||||
(*SetCartRequest)(nil), // 1: messages.SetCartRequest
|
||||
@@ -1024,6 +1125,8 @@ var file_messages_proto_goTypes = []any{
|
||||
(*RemoveDelivery)(nil), // 8: messages.RemoveDelivery
|
||||
(*CreateCheckoutOrder)(nil), // 9: messages.CreateCheckoutOrder
|
||||
(*OrderCreated)(nil), // 10: messages.OrderCreated
|
||||
(*Noop)(nil), // 11: messages.Noop
|
||||
(*InitializeCheckout)(nil), // 12: messages.InitializeCheckout
|
||||
}
|
||||
var file_messages_proto_depIdxs = []int32{
|
||||
0, // 0: messages.SetCartRequest.items:type_name -> messages.AddRequest
|
||||
@@ -1051,7 +1154,7 @@ func file_messages_proto_init() {
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: unsafe.Slice(unsafe.StringData(file_messages_proto_rawDesc), len(file_messages_proto_rawDesc)),
|
||||
NumEnums: 0,
|
||||
NumMessages: 11,
|
||||
NumMessages: 13,
|
||||
NumExtensions: 0,
|
||||
NumServices: 0,
|
||||
},
|
||||
|
||||
@@ -93,3 +93,13 @@ message OrderCreated {
|
||||
string orderId = 1;
|
||||
string status = 2;
|
||||
}
|
||||
|
||||
message Noop {
|
||||
// Intentionally empty - used for ownership acquisition or health pings
|
||||
}
|
||||
|
||||
message InitializeCheckout {
|
||||
string orderId = 1;
|
||||
string status = 2;
|
||||
bool paymentInProgress = 3;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user