Documentation
¶
Overview ¶
Package service impls app services
Package service impls app services ¶
Package service impls app services
Index ¶
- Variables
- type DiskImageStore
- type ImageInfo
- type ImageStore
- type InMemoryLaptopStore
- type LaptopServer
- func (server *LaptopServer) CreateLaptop(ctx context.Context, req *pb.CreateLaptopRequest) (*pb.CreateLaptopResponse, error)
- func (server *LaptopServer) SearchLaptop(req *pb.SearchLaptopRequest, stream pb.LaptopService_SearchLaptopServer) error
- func (server *LaptopServer) UploadImage(stream pb.LaptopService_UploadImageServer) error
- type LaptopStore
Constants ¶
This section is empty.
Variables ¶
var ErrAlreadyExists = errors.New("record already exists")
ErrAlreadyExists is returned when a record with the same ID already exists in the store
Functions ¶
This section is empty.
Types ¶
type DiskImageStore ¶
type DiskImageStore struct {
// contains filtered or unexported fields
}
DiskImageStore stores image on disk, and its info on memory
func NewDiskImageStore ¶
func NewDiskImageStore(imageFolder string) *DiskImageStore
NewDiskImageStore returns a new DiskImageStore
type ImageStore ¶
type ImageStore interface { // Save saves a new laptop image to the store Save(laptopID string, imageType string, imageData bytes.Buffer) (string, error) }
ImageStore is an interface to store laptop images
type InMemoryLaptopStore ¶
type InMemoryLaptopStore struct {
// contains filtered or unexported fields
}
InMemoryLaptopStore stores laptop in memory
func NewInMemoryLaptopStore ¶
func NewInMemoryLaptopStore() *InMemoryLaptopStore
NewInMemoryLaptopStore returns a new InMemoryLaptopStore
func (*InMemoryLaptopStore) Find ¶
func (store *InMemoryLaptopStore) Find(id string) (*pb.Laptop, error)
Find finds a laptop by ID
type LaptopServer ¶
type LaptopServer struct {
// contains filtered or unexported fields
}
LaptopServer is the server that provides laptop services
func NewLaptopServer ¶
func NewLaptopServer(laptopStore LaptopStore, imageStore ImageStore) *LaptopServer
NewLaptopServer returns a new laptopServer
func (*LaptopServer) CreateLaptop ¶
func (server *LaptopServer) CreateLaptop( ctx context.Context, req *pb.CreateLaptopRequest, ) (*pb.CreateLaptopResponse, error)
CreateLaptop is a unary RPC to create a new laptop
func (*LaptopServer) SearchLaptop ¶
func (server *LaptopServer) SearchLaptop( req *pb.SearchLaptopRequest, stream pb.LaptopService_SearchLaptopServer, ) error
SearchLaptop is a server-streaming RPC to search for laptops
func (*LaptopServer) UploadImage ¶
func (server *LaptopServer) UploadImage(stream pb.LaptopService_UploadImageServer) error
UploadImage is a client-streaming RPC to upload a laptop image
type LaptopStore ¶
type LaptopStore interface { // Save saves the laptop to the Store Save(laptop *pb.Laptop) error // Find finds a laptop by ID Find(id string) (*pb.Laptop, error) // Search searches for laptops with filter, returns one by one via the found function Search(ctx context.Context, filter *pb.Filter, found func(laptop *pb.Laptop) error) error }
LaptopStore is an interface to store laptop