Documentation ¶
Overview ¶
Package product is a reverse proxy.
It translates gRPC into RESTful JSON APIs.
Index ¶
- Variables
- func RegisterProductServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error
- func RegisterProductServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client ProductServiceClient) error
- func RegisterProductServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, ...) (err error)
- func RegisterProductServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server ProductServiceServer) error
- func RegisterProductServiceServer(s grpc.ServiceRegistrar, srv ProductServiceServer)
- type GetProductRequest
- type GetProductResponse
- func (*GetProductResponse) Descriptor() ([]byte, []int)deprecated
- func (x *GetProductResponse) GetProduct() *Product
- func (*GetProductResponse) ProtoMessage()
- func (x *GetProductResponse) ProtoReflect() protoreflect.Message
- func (x *GetProductResponse) Reset()
- func (x *GetProductResponse) String() string
- type Product
- func (*Product) Descriptor() ([]byte, []int)deprecated
- func (x *Product) GetCategory() string
- func (x *Product) GetId() string
- func (x *Product) GetName() string
- func (x *Product) GetPrice() int32
- func (x *Product) GetQuantity() int32
- func (*Product) ProtoMessage()
- func (x *Product) ProtoReflect() protoreflect.Message
- func (x *Product) Reset()
- func (x *Product) String() string
- type ProductCatalogue
- type ProductServiceClient
- type ProductServiceServer
- type UnimplementedProductServiceServer
- func (UnimplementedProductServiceServer) AddProduct(context.Context, *Product) (*GetProductResponse, error)
- func (UnimplementedProductServiceServer) GetProduct(context.Context, *GetProductRequest) (*GetProductResponse, error)
- func (UnimplementedProductServiceServer) GetProductCatalogue(context.Context, *emptypb.Empty) (*ProductCatalogue, error)
- func (UnimplementedProductServiceServer) UpdateProduct(context.Context, *Product) (*Product, error)
- type UnsafeProductServiceServer
Constants ¶
This section is empty.
Variables ¶
var File_protos_product_product_proto protoreflect.FileDescriptor
var ProductService_ServiceDesc = grpc.ServiceDesc{ ServiceName: "productpb.ProductService", HandlerType: (*ProductServiceServer)(nil), Methods: []grpc.MethodDesc{ { MethodName: "AddProduct", Handler: _ProductService_AddProduct_Handler, }, { MethodName: "GetProduct", Handler: _ProductService_GetProduct_Handler, }, { MethodName: "GetProductCatalogue", Handler: _ProductService_GetProductCatalogue_Handler, }, { MethodName: "UpdateProduct", Handler: _ProductService_UpdateProduct_Handler, }, }, Streams: []grpc.StreamDesc{}, Metadata: "protos/product/product.proto", }
ProductService_ServiceDesc is the grpc.ServiceDesc for ProductService service. It's only intended for direct use with grpc.RegisterService, and not to be introspected or modified (even as a copy)
Functions ¶
func RegisterProductServiceHandler ¶
func RegisterProductServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error
RegisterProductServiceHandler registers the http handlers for service ProductService to "mux". The handlers forward requests to the grpc endpoint over "conn".
func RegisterProductServiceHandlerClient ¶
func RegisterProductServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client ProductServiceClient) error
RegisterProductServiceHandlerClient registers the http handlers for service ProductService to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "ProductServiceClient". Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "ProductServiceClient" doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in "ProductServiceClient" to call the correct interceptors.
func RegisterProductServiceHandlerFromEndpoint ¶
func RegisterProductServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error)
RegisterProductServiceHandlerFromEndpoint is same as RegisterProductServiceHandler but automatically dials to "endpoint" and closes the connection when "ctx" gets done.
func RegisterProductServiceHandlerServer ¶
func RegisterProductServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server ProductServiceServer) error
RegisterProductServiceHandlerServer registers the http handlers for service ProductService to "mux". UnaryRPC :call ProductServiceServer directly. StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterProductServiceHandlerFromEndpoint instead.
func RegisterProductServiceServer ¶
func RegisterProductServiceServer(s grpc.ServiceRegistrar, srv ProductServiceServer)
Types ¶
type GetProductRequest ¶
type GetProductRequest struct { Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` // contains filtered or unexported fields }
func (*GetProductRequest) Descriptor
deprecated
func (*GetProductRequest) Descriptor() ([]byte, []int)
Deprecated: Use GetProductRequest.ProtoReflect.Descriptor instead.
func (*GetProductRequest) GetId ¶
func (x *GetProductRequest) GetId() string
func (*GetProductRequest) ProtoMessage ¶
func (*GetProductRequest) ProtoMessage()
func (*GetProductRequest) ProtoReflect ¶
func (x *GetProductRequest) ProtoReflect() protoreflect.Message
func (*GetProductRequest) Reset ¶
func (x *GetProductRequest) Reset()
func (*GetProductRequest) String ¶
func (x *GetProductRequest) String() string
type GetProductResponse ¶
type GetProductResponse struct { Product *Product `protobuf:"bytes,1,opt,name=product,proto3" json:"product,omitempty"` // contains filtered or unexported fields }
func (*GetProductResponse) Descriptor
deprecated
func (*GetProductResponse) Descriptor() ([]byte, []int)
Deprecated: Use GetProductResponse.ProtoReflect.Descriptor instead.
func (*GetProductResponse) GetProduct ¶
func (x *GetProductResponse) GetProduct() *Product
func (*GetProductResponse) ProtoMessage ¶
func (*GetProductResponse) ProtoMessage()
func (*GetProductResponse) ProtoReflect ¶
func (x *GetProductResponse) ProtoReflect() protoreflect.Message
func (*GetProductResponse) Reset ¶
func (x *GetProductResponse) Reset()
func (*GetProductResponse) String ¶
func (x *GetProductResponse) String() string
type Product ¶
type Product struct { Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` Category string `protobuf:"bytes,3,opt,name=category,proto3" json:"category,omitempty"` Price int32 `protobuf:"varint,4,opt,name=price,proto3" json:"price,omitempty"` Quantity int32 `protobuf:"varint,5,opt,name=quantity,proto3" json:"quantity,omitempty"` // contains filtered or unexported fields }
func (*Product) Descriptor
deprecated
func (*Product) GetCategory ¶
func (*Product) GetQuantity ¶
func (*Product) ProtoMessage ¶
func (*Product) ProtoMessage()
func (*Product) ProtoReflect ¶
func (x *Product) ProtoReflect() protoreflect.Message
type ProductCatalogue ¶
type ProductCatalogue struct { Products []*Product `protobuf:"bytes,1,rep,name=products,proto3" json:"products,omitempty"` // contains filtered or unexported fields }
func (*ProductCatalogue) Descriptor
deprecated
func (*ProductCatalogue) Descriptor() ([]byte, []int)
Deprecated: Use ProductCatalogue.ProtoReflect.Descriptor instead.
func (*ProductCatalogue) GetProducts ¶
func (x *ProductCatalogue) GetProducts() []*Product
func (*ProductCatalogue) ProtoMessage ¶
func (*ProductCatalogue) ProtoMessage()
func (*ProductCatalogue) ProtoReflect ¶
func (x *ProductCatalogue) ProtoReflect() protoreflect.Message
func (*ProductCatalogue) Reset ¶
func (x *ProductCatalogue) Reset()
func (*ProductCatalogue) String ¶
func (x *ProductCatalogue) String() string
type ProductServiceClient ¶
type ProductServiceClient interface { AddProduct(ctx context.Context, in *Product, opts ...grpc.CallOption) (*GetProductResponse, error) GetProduct(ctx context.Context, in *GetProductRequest, opts ...grpc.CallOption) (*GetProductResponse, error) GetProductCatalogue(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*ProductCatalogue, error) UpdateProduct(ctx context.Context, in *Product, opts ...grpc.CallOption) (*Product, error) }
ProductServiceClient is the client API for ProductService service.
For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
func NewProductServiceClient ¶
func NewProductServiceClient(cc grpc.ClientConnInterface) ProductServiceClient
type ProductServiceServer ¶
type ProductServiceServer interface { AddProduct(context.Context, *Product) (*GetProductResponse, error) GetProduct(context.Context, *GetProductRequest) (*GetProductResponse, error) GetProductCatalogue(context.Context, *emptypb.Empty) (*ProductCatalogue, error) UpdateProduct(context.Context, *Product) (*Product, error) // contains filtered or unexported methods }
ProductServiceServer is the server API for ProductService service. All implementations must embed UnimplementedProductServiceServer for forward compatibility
type UnimplementedProductServiceServer ¶
type UnimplementedProductServiceServer struct { }
UnimplementedProductServiceServer must be embedded to have forward compatible implementations.
func (UnimplementedProductServiceServer) AddProduct ¶
func (UnimplementedProductServiceServer) AddProduct(context.Context, *Product) (*GetProductResponse, error)
func (UnimplementedProductServiceServer) GetProduct ¶
func (UnimplementedProductServiceServer) GetProduct(context.Context, *GetProductRequest) (*GetProductResponse, error)
func (UnimplementedProductServiceServer) GetProductCatalogue ¶
func (UnimplementedProductServiceServer) GetProductCatalogue(context.Context, *emptypb.Empty) (*ProductCatalogue, error)
func (UnimplementedProductServiceServer) UpdateProduct ¶
type UnsafeProductServiceServer ¶
type UnsafeProductServiceServer interface {
// contains filtered or unexported methods
}
UnsafeProductServiceServer may be embedded to opt out of forward compatibility for this service. Use of this interface is not recommended, as added methods to ProductServiceServer will result in compilation errors.