Documentation ¶
Index ¶
- Variables
- func NewShoppingCart(eventsourced.EntityID) eventsourced.EntityHandler
- func RegisterShoppingCartServer(s *grpc.Server, srv ShoppingCartServer)
- type AddLineItem
- func (*AddLineItem) Descriptor() ([]byte, []int)deprecated
- func (x *AddLineItem) GetName() string
- func (x *AddLineItem) GetProductId() string
- func (x *AddLineItem) GetQuantity() int32
- func (x *AddLineItem) GetUserId() string
- func (*AddLineItem) ProtoMessage()
- func (x *AddLineItem) ProtoReflect() protoreflect.Message
- func (x *AddLineItem) Reset()
- func (x *AddLineItem) String() string
- type Cart
- type GetShoppingCart
- type LineItem
- func (*LineItem) Descriptor() ([]byte, []int)deprecated
- func (x *LineItem) GetName() string
- func (x *LineItem) GetProductId() string
- func (x *LineItem) GetQuantity() int32
- func (*LineItem) ProtoMessage()
- func (x *LineItem) ProtoReflect() protoreflect.Message
- func (x *LineItem) Reset()
- func (x *LineItem) String() string
- type RemoveLineItem
- func (*RemoveLineItem) Descriptor() ([]byte, []int)deprecated
- func (x *RemoveLineItem) GetProductId() string
- func (x *RemoveLineItem) GetUserId() string
- func (*RemoveLineItem) ProtoMessage()
- func (x *RemoveLineItem) ProtoReflect() protoreflect.Message
- func (x *RemoveLineItem) Reset()
- func (x *RemoveLineItem) String() string
- type ShoppingCart
- func (sc *ShoppingCart) AddItem(ctx *eventsourced.Context, li *AddLineItem) (*empty.Empty, error)
- func (sc *ShoppingCart) GetCart(*eventsourced.Context, *GetShoppingCart) (*Cart, error)
- func (sc *ShoppingCart) HandleCommand(ctx *eventsourced.Context, name string, cmd proto.Message) (proto.Message, error)
- func (sc *ShoppingCart) HandleEvent(ctx *eventsourced.Context, event interface{}) error
- func (sc *ShoppingCart) HandleSnapshot(ctx *eventsourced.Context, snapshot interface{}) error
- func (sc *ShoppingCart) ItemAdded(added *domain.ItemAdded) error
- func (sc *ShoppingCart) ItemRemoved(removed *domain.ItemRemoved) error
- func (sc *ShoppingCart) RemoveItem(ctx *eventsourced.Context, li *RemoveLineItem) (*empty.Empty, error)
- func (sc *ShoppingCart) Snapshot(*eventsourced.Context) (snapshot interface{}, err error)
- type ShoppingCartClient
- type ShoppingCartServer
- type UnimplementedShoppingCartServer
- func (*UnimplementedShoppingCartServer) AddItem(context.Context, *AddLineItem) (*empty.Empty, error)
- func (*UnimplementedShoppingCartServer) GetCart(context.Context, *GetShoppingCart) (*Cart, error)
- func (*UnimplementedShoppingCartServer) RemoveItem(context.Context, *RemoveLineItem) (*empty.Empty, error)
Constants ¶
This section is empty.
Variables ¶
var File_shoppingcart_proto protoreflect.FileDescriptor
Functions ¶
func NewShoppingCart ¶
func NewShoppingCart(eventsourced.EntityID) eventsourced.EntityHandler
NewShoppingCart returns a new and initialized instance of the ShoppingCart entity. tag::entity-func[]
func RegisterShoppingCartServer ¶
func RegisterShoppingCartServer(s *grpc.Server, srv ShoppingCartServer)
Types ¶
type AddLineItem ¶
type AddLineItem struct { UserId string `protobuf:"bytes,1,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"` ProductId string `protobuf:"bytes,2,opt,name=product_id,json=productId,proto3" json:"product_id,omitempty"` Name string `protobuf:"bytes,3,opt,name=name,proto3" json:"name,omitempty"` Quantity int32 `protobuf:"varint,4,opt,name=quantity,proto3" json:"quantity,omitempty"` // contains filtered or unexported fields }
func (*AddLineItem) Descriptor
deprecated
func (*AddLineItem) Descriptor() ([]byte, []int)
Deprecated: Use AddLineItem.ProtoReflect.Descriptor instead.
func (*AddLineItem) GetName ¶
func (x *AddLineItem) GetName() string
func (*AddLineItem) GetProductId ¶
func (x *AddLineItem) GetProductId() string
func (*AddLineItem) GetQuantity ¶
func (x *AddLineItem) GetQuantity() int32
func (*AddLineItem) GetUserId ¶
func (x *AddLineItem) GetUserId() string
func (*AddLineItem) ProtoMessage ¶
func (*AddLineItem) ProtoMessage()
func (*AddLineItem) ProtoReflect ¶
func (x *AddLineItem) ProtoReflect() protoreflect.Message
func (*AddLineItem) Reset ¶
func (x *AddLineItem) Reset()
func (*AddLineItem) String ¶
func (x *AddLineItem) String() string
type Cart ¶
type Cart struct { Items []*LineItem `protobuf:"bytes,1,rep,name=items,proto3" json:"items,omitempty"` // contains filtered or unexported fields }
func (*Cart) Descriptor
deprecated
func (*Cart) ProtoMessage ¶
func (*Cart) ProtoMessage()
func (*Cart) ProtoReflect ¶
func (x *Cart) ProtoReflect() protoreflect.Message
type GetShoppingCart ¶
type GetShoppingCart struct { UserId string `protobuf:"bytes,1,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"` // contains filtered or unexported fields }
func (*GetShoppingCart) Descriptor
deprecated
func (*GetShoppingCart) Descriptor() ([]byte, []int)
Deprecated: Use GetShoppingCart.ProtoReflect.Descriptor instead.
func (*GetShoppingCart) GetUserId ¶
func (x *GetShoppingCart) GetUserId() string
func (*GetShoppingCart) ProtoMessage ¶
func (*GetShoppingCart) ProtoMessage()
func (*GetShoppingCart) ProtoReflect ¶
func (x *GetShoppingCart) ProtoReflect() protoreflect.Message
func (*GetShoppingCart) Reset ¶
func (x *GetShoppingCart) Reset()
func (*GetShoppingCart) String ¶
func (x *GetShoppingCart) String() string
type LineItem ¶
type LineItem struct { ProductId string `protobuf:"bytes,1,opt,name=product_id,json=productId,proto3" json:"product_id,omitempty"` Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` Quantity int32 `protobuf:"varint,3,opt,name=quantity,proto3" json:"quantity,omitempty"` // contains filtered or unexported fields }
func (*LineItem) Descriptor
deprecated
func (*LineItem) GetProductId ¶
func (*LineItem) GetQuantity ¶
func (*LineItem) ProtoMessage ¶
func (*LineItem) ProtoMessage()
func (*LineItem) ProtoReflect ¶
func (x *LineItem) ProtoReflect() protoreflect.Message
type RemoveLineItem ¶
type RemoveLineItem struct { UserId string `protobuf:"bytes,1,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"` ProductId string `protobuf:"bytes,2,opt,name=product_id,json=productId,proto3" json:"product_id,omitempty"` // contains filtered or unexported fields }
func (*RemoveLineItem) Descriptor
deprecated
func (*RemoveLineItem) Descriptor() ([]byte, []int)
Deprecated: Use RemoveLineItem.ProtoReflect.Descriptor instead.
func (*RemoveLineItem) GetProductId ¶
func (x *RemoveLineItem) GetProductId() string
func (*RemoveLineItem) GetUserId ¶
func (x *RemoveLineItem) GetUserId() string
func (*RemoveLineItem) ProtoMessage ¶
func (*RemoveLineItem) ProtoMessage()
func (*RemoveLineItem) ProtoReflect ¶
func (x *RemoveLineItem) ProtoReflect() protoreflect.Message
func (*RemoveLineItem) Reset ¶
func (x *RemoveLineItem) Reset()
func (*RemoveLineItem) String ¶
func (x *RemoveLineItem) String() string
type ShoppingCart ¶
type ShoppingCart struct {
// contains filtered or unexported fields
}
A Cloudstate event sourced entity implementing a shopping cart. tag::entity-type[] tag::entity-state[]
func (*ShoppingCart) AddItem ¶
func (sc *ShoppingCart) AddItem(ctx *eventsourced.Context, li *AddLineItem) (*empty.Empty, error)
AddItem implements the AddItem command handling of the shopping cart service. tag::add-item[]
func (*ShoppingCart) GetCart ¶
func (sc *ShoppingCart) GetCart(*eventsourced.Context, *GetShoppingCart) (*Cart, error)
GetCart implements the GetCart command handling of the shopping cart service. tag::get-cart[]
func (*ShoppingCart) HandleCommand ¶
func (sc *ShoppingCart) HandleCommand(ctx *eventsourced.Context, name string, cmd proto.Message) (proto.Message, error)
HandleCommand is the entities command handler implemented by the shopping cart. tag::handle-command[]
func (*ShoppingCart) HandleEvent ¶
func (sc *ShoppingCart) HandleEvent(ctx *eventsourced.Context, event interface{}) error
HandleEvent lets us handle events by ourselves. tag::handle-event[]
func (*ShoppingCart) HandleSnapshot ¶
func (sc *ShoppingCart) HandleSnapshot(ctx *eventsourced.Context, snapshot interface{}) error
HandleSnapshot applies given snapshot to be the current state. tag::handle-snapshot[]
func (*ShoppingCart) ItemAdded ¶
func (sc *ShoppingCart) ItemAdded(added *domain.ItemAdded) error
ItemAdded is a event handler function for the ItemAdded event. tag::item-added[]
func (*ShoppingCart) ItemRemoved ¶
func (sc *ShoppingCart) ItemRemoved(removed *domain.ItemRemoved) error
ItemRemoved is a event handler function for the ItemRemoved event.
func (*ShoppingCart) RemoveItem ¶
func (sc *ShoppingCart) RemoveItem(ctx *eventsourced.Context, li *RemoveLineItem) (*empty.Empty, error)
RemoveItem implements the RemoveItem command handling of the shopping cart service.
func (*ShoppingCart) Snapshot ¶
func (sc *ShoppingCart) Snapshot(*eventsourced.Context) (snapshot interface{}, err error)
Snapshot returns the current state of the shopping cart. tag::snapshot[]
type ShoppingCartClient ¶
type ShoppingCartClient interface { AddItem(ctx context.Context, in *AddLineItem, opts ...grpc.CallOption) (*empty.Empty, error) RemoveItem(ctx context.Context, in *RemoveLineItem, opts ...grpc.CallOption) (*empty.Empty, error) GetCart(ctx context.Context, in *GetShoppingCart, opts ...grpc.CallOption) (*Cart, error) }
ShoppingCartClient is the client API for ShoppingCart service.
For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
func NewShoppingCartClient ¶
func NewShoppingCartClient(cc grpc.ClientConnInterface) ShoppingCartClient
type ShoppingCartServer ¶
type ShoppingCartServer interface { AddItem(context.Context, *AddLineItem) (*empty.Empty, error) RemoveItem(context.Context, *RemoveLineItem) (*empty.Empty, error) GetCart(context.Context, *GetShoppingCart) (*Cart, error) }
ShoppingCartServer is the server API for ShoppingCart service.
type UnimplementedShoppingCartServer ¶
type UnimplementedShoppingCartServer struct { }
UnimplementedShoppingCartServer can be embedded to have forward compatible implementations.
func (*UnimplementedShoppingCartServer) AddItem ¶
func (*UnimplementedShoppingCartServer) AddItem(context.Context, *AddLineItem) (*empty.Empty, error)
func (*UnimplementedShoppingCartServer) GetCart ¶
func (*UnimplementedShoppingCartServer) GetCart(context.Context, *GetShoppingCart) (*Cart, error)
func (*UnimplementedShoppingCartServer) RemoveItem ¶
func (*UnimplementedShoppingCartServer) RemoveItem(context.Context, *RemoveLineItem) (*empty.Empty, error)