product

package
v0.0.0-...-1aac047 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2018 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeCreateProductRequest

func DecodeCreateProductRequest(_ context.Context, r interface{}) (interface{}, error)

func DecodeGetProductRequest

func DecodeGetProductRequest(_ context.Context, r interface{}) (interface{}, error)

func EncodeProductResponse

func EncodeProductResponse(_ context.Context, r interface{}) (interface{}, error)

func MakeCreateProductEndpoint

func MakeCreateProductEndpoint(svc Service) endpoint.Endpoint

func MakeGetProductEndpoint

func MakeGetProductEndpoint(svc Service) endpoint.Endpoint

func NewGRPCServer

func NewGRPCServer(_ context.Context, endpoint Endpoints) pb.ProductServer

Types

type CreateProductRequest

type CreateProductRequest struct {
	Name string
}

type Endpoints

type Endpoints struct {
	GetProductEndpoint    endpoint.Endpoint
	CreateProductEndpoint endpoint.Endpoint
}

type GRPCServer

type GRPCServer struct {
	// contains filtered or unexported fields
}

func (*GRPCServer) CreateProduct

func (s *GRPCServer) CreateProduct(ctx context.Context, req *pb.CreateProductRequest) (*pb.ProductResponse, error)

func (*GRPCServer) GetProduct

func (s *GRPCServer) GetProduct(ctx context.Context, req *pb.GetProductRequest) (*pb.ProductResponse, error)

type GetProductRequest

type GetProductRequest struct {
	ID int32
}

type ProductResponse

type ProductResponse struct {
	ID   int32
	Name string
}

type ProductService

type ProductService struct {
	Repository database.ProductRepository
}

func (*ProductService) CreateProduct

func (s *ProductService) CreateProduct(name string) (*database.Product, error)

func (*ProductService) GetProduct

func (s *ProductService) GetProduct(id int32) (*database.Product, error)

type Service

type Service interface {
	GetProduct(id int32) (*database.Product, error)
	CreateProduct(name string) (*database.Product, error)
}

Jump to

Keyboard shortcuts

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