shoppingcart

package
v0.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 15, 2020 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var File_shoppingcart_proto protoreflect.FileDescriptor

Functions

func NewShoppingCart

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) Descriptor() ([]byte, []int)

Deprecated: Use Cart.ProtoReflect.Descriptor instead.

func (*Cart) GetItems

func (x *Cart) GetItems() []*LineItem

func (*Cart) ProtoMessage

func (*Cart) ProtoMessage()

func (*Cart) ProtoReflect

func (x *Cart) ProtoReflect() protoreflect.Message

func (*Cart) Reset

func (x *Cart) Reset()

func (*Cart) String

func (x *Cart) String() string

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) Descriptor() ([]byte, []int)

Deprecated: Use LineItem.ProtoReflect.Descriptor instead.

func (*LineItem) GetName

func (x *LineItem) GetName() string

func (*LineItem) GetProductId

func (x *LineItem) GetProductId() string

func (*LineItem) GetQuantity

func (x *LineItem) GetQuantity() int32

func (*LineItem) ProtoMessage

func (*LineItem) ProtoMessage()

func (*LineItem) ProtoReflect

func (x *LineItem) ProtoReflect() protoreflect.Message

func (*LineItem) Reset

func (x *LineItem) Reset()

func (*LineItem) String

func (x *LineItem) String() string

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

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.

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) GetCart

func (*UnimplementedShoppingCartServer) RemoveItem

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL