Documentation
¶
Overview ¶
Package cart provides shopping cart functionality. It exposes gRPC API and uses SQL DB as storage.
Index ¶
- type Cart
- type Carts
- func (c *Carts) AddProduct(ctx context.Context, cartID, productID int64, quantity uint32) error
- func (c *Carts) Cart(ctx context.Context, id int64) (Cart, error)
- func (c *Carts) Create(ctx context.Context, userID int64) (Cart, error)
- func (c *Carts) Delete(ctx context.Context, cartID int64) error
- func (c *Carts) DeleteProduct(ctx context.Context, cartID, productID int64) error
- func (c *Carts) Empty(ctx context.Context, cartID int64) error
- type LineItem
- type Server
- func (s *Server) AddProduct(ctx context.Context, req *proto.AddProductRequest) (*empty.Empty, error)
- func (s *Server) CreateCart(ctx context.Context, req *proto.CartCreateRequest) (*proto.CartResponse, error)
- func (s *Server) DelProduct(ctx context.Context, req *proto.DelProductRequest) (*empty.Empty, error)
- func (s *Server) DeleteCart(ctx context.Context, req *proto.CartDeleteRequest) (*empty.Empty, error)
- func (s *Server) EmptyCart(ctx context.Context, req *proto.EmptyCartRequest) (*empty.Empty, error)
- func (s *Server) GetCart(ctx context.Context, req *proto.CartRequest) (*proto.CartResponse, error)
- type Storage
- func (s *Storage) AddProduct(ctx context.Context, cartID, productID int64, quantity uint32) error
- func (s *Storage) CartByID(ctx context.Context, id int64) (Cart, error)
- func (s *Storage) CreateCart(ctx context.Context, cart Cart) (Cart, error)
- func (s *Storage) DeleteCart(ctx context.Context, cartID int64) error
- func (s *Storage) DeleteLineItems(ctx context.Context, cartID int64) error
- func (s *Storage) DeleteProduct(ctx context.Context, cartID, productID int64) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Carts ¶
type Carts struct {
// contains filtered or unexported fields
}
Carts contains all business logic realated to this microservice.
func New ¶
func New(s storage) *Carts
New builds and returns new instance of Carts that is ready for use.
func (*Carts) AddProduct ¶
AddProduct to a Cart.
func (*Carts) DeleteProduct ¶
DeleteProduct in a Cart.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server implements protobuf Carts service.
func (*Server) AddProduct ¶
func (s *Server) AddProduct(ctx context.Context, req *proto.AddProductRequest) (*empty.Empty, error)
AddProduct to a Cart.
func (*Server) CreateCart ¶
func (s *Server) CreateCart(ctx context.Context, req *proto.CartCreateRequest) (*proto.CartResponse, error)
CreateCart for a User.
func (*Server) DelProduct ¶
func (s *Server) DelProduct(ctx context.Context, req *proto.DelProductRequest) (*empty.Empty, error)
DelProduct removes product from a Cart.
func (*Server) DeleteCart ¶
func (s *Server) DeleteCart(ctx context.Context, req *proto.CartDeleteRequest) (*empty.Empty, error)
DeleteCart with the matching ID.
func (*Server) GetCart ¶
func (s *Server) GetCart(ctx context.Context, req *proto.CartRequest) (*proto.CartResponse, error)
GetCart returns current Cart state.
type Storage ¶
type Storage struct {
// contains filtered or unexported fields
}
func NewStorage ¶
func (*Storage) AddProduct ¶
func (*Storage) CreateCart ¶
func (*Storage) DeleteLineItems ¶
Click to show internal directories.
Click to hide internal directories.