Documentation ¶
Overview ¶
Package pb is a reverse proxy.
It translates gRPC into RESTful JSON APIs.
Index ¶
- Constants
- 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 CreateProductRequest
- func (*CreateProductRequest) Descriptor() ([]byte, []int)deprecated
- func (x *CreateProductRequest) GetCategory() string
- func (x *CreateProductRequest) GetDescription() string
- func (x *CreateProductRequest) GetName() string
- func (x *CreateProductRequest) GetPrice() int64
- func (x *CreateProductRequest) GetStatus() ProductStatus
- func (x *CreateProductRequest) GetTags() []string
- func (*CreateProductRequest) ProtoMessage()
- func (x *CreateProductRequest) ProtoReflect() protoreflect.Message
- func (x *CreateProductRequest) Reset()
- func (x *CreateProductRequest) String() string
- type CreateProductResponse
- func (*CreateProductResponse) Descriptor() ([]byte, []int)deprecated
- func (x *CreateProductResponse) GetProduct() *Product
- func (*CreateProductResponse) ProtoMessage()
- func (x *CreateProductResponse) ProtoReflect() protoreflect.Message
- func (x *CreateProductResponse) Reset()
- func (x *CreateProductResponse) String() string
- type Order
- type Product
- func (*Product) Descriptor() ([]byte, []int)deprecated
- func (x *Product) GetCategory() string
- func (x *Product) GetDescription() string
- func (x *Product) GetId() string
- func (x *Product) GetName() string
- func (x *Product) GetPrice() int64
- func (x *Product) GetStatus() ProductStatus
- func (x *Product) GetTags() []string
- func (*Product) ProtoMessage()
- func (x *Product) ProtoReflect() protoreflect.Message
- func (x *Product) Reset()
- func (x *Product) String() string
- type ProductServiceClient
- type ProductServiceServer
- type ProductStatus
- func (ProductStatus) Descriptor() protoreflect.EnumDescriptor
- func (x ProductStatus) Enum() *ProductStatus
- func (ProductStatus) EnumDescriptor() ([]byte, []int)deprecated
- func (x ProductStatus) Number() protoreflect.EnumNumber
- func (x ProductStatus) String() string
- func (ProductStatus) Type() protoreflect.EnumType
- type ProductStock
- func (*ProductStock) Descriptor() ([]byte, []int)deprecated
- func (x *ProductStock) GetId() int32
- func (x *ProductStock) GetLocation() string
- func (x *ProductStock) GetProductId() string
- func (x *ProductStock) GetStatus() ProductStockStatus
- func (*ProductStock) ProtoMessage()
- func (x *ProductStock) ProtoReflect() protoreflect.Message
- func (x *ProductStock) Reset()
- func (x *ProductStock) String() string
- type ProductStockStatus
- func (ProductStockStatus) Descriptor() protoreflect.EnumDescriptor
- func (x ProductStockStatus) Enum() *ProductStockStatus
- func (ProductStockStatus) EnumDescriptor() ([]byte, []int)deprecated
- func (x ProductStockStatus) Number() protoreflect.EnumNumber
- func (x ProductStockStatus) String() string
- func (ProductStockStatus) Type() protoreflect.EnumType
- type UnimplementedProductServiceServer
- type UnsafeProductServiceServer
Constants ¶
const (
ProductService_CreateProduct_FullMethodName = "/com.ecommerce.api.v1.ProductService/CreateProduct"
)
Variables ¶
var ( ProductStatus_name = map[int32]string{ 0: "ACTIVE", 1: "INACTIVE", } ProductStatus_value = map[string]int32{ "ACTIVE": 0, "INACTIVE": 1, } )
Enum value maps for ProductStatus.
var ( ProductStockStatus_name = map[int32]string{ 0: "AVAILABLE", 1: "RESERVED", 2: "SOLD", } ProductStockStatus_value = map[string]int32{ "AVAILABLE": 0, "RESERVED": 1, "SOLD": 2, } )
Enum value maps for ProductStockStatus.
var File_document_proto protoreflect.FileDescriptor
var File_order_proto protoreflect.FileDescriptor
var File_product_proto protoreflect.FileDescriptor
var ProductService_ServiceDesc = grpc.ServiceDesc{ ServiceName: "com.ecommerce.api.v1.ProductService", HandlerType: (*ProductServiceServer)(nil), Methods: []grpc.MethodDesc{ { MethodName: "CreateProduct", Handler: _ProductService_CreateProduct_Handler, }, }, Streams: []grpc.StreamDesc{}, Metadata: "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. This client ignores the HTTP middlewares.
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. GRPC interceptors will not work for this type of registration. To use interceptors, you must use the "runtime.WithMiddlewares" option in the "runtime.NewServeMux" call.
func RegisterProductServiceServer ¶
func RegisterProductServiceServer(s grpc.ServiceRegistrar, srv ProductServiceServer)
Types ¶
type CreateProductRequest ¶
type CreateProductRequest struct { Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"` Category string `protobuf:"bytes,3,opt,name=category,proto3" json:"category,omitempty"` Price int64 `protobuf:"varint,4,opt,name=price,proto3" json:"price,omitempty"` Status ProductStatus `protobuf:"varint,5,opt,name=status,proto3,enum=com.ecommerce.api.v1.ProductStatus" json:"status,omitempty"` Tags []string `protobuf:"bytes,6,rep,name=tags,proto3" json:"tags,omitempty"` // Add tags as repeated field // contains filtered or unexported fields }
Request message for creating a product
func (*CreateProductRequest) Descriptor
deprecated
func (*CreateProductRequest) Descriptor() ([]byte, []int)
Deprecated: Use CreateProductRequest.ProtoReflect.Descriptor instead.
func (*CreateProductRequest) GetCategory ¶
func (x *CreateProductRequest) GetCategory() string
func (*CreateProductRequest) GetDescription ¶
func (x *CreateProductRequest) GetDescription() string
func (*CreateProductRequest) GetName ¶
func (x *CreateProductRequest) GetName() string
func (*CreateProductRequest) GetPrice ¶
func (x *CreateProductRequest) GetPrice() int64
func (*CreateProductRequest) GetStatus ¶
func (x *CreateProductRequest) GetStatus() ProductStatus
func (*CreateProductRequest) GetTags ¶
func (x *CreateProductRequest) GetTags() []string
func (*CreateProductRequest) ProtoMessage ¶
func (*CreateProductRequest) ProtoMessage()
func (*CreateProductRequest) ProtoReflect ¶
func (x *CreateProductRequest) ProtoReflect() protoreflect.Message
func (*CreateProductRequest) Reset ¶
func (x *CreateProductRequest) Reset()
func (*CreateProductRequest) String ¶
func (x *CreateProductRequest) String() string
type CreateProductResponse ¶
type CreateProductResponse struct { Product *Product `protobuf:"bytes,1,opt,name=product,proto3" json:"product,omitempty"` // contains filtered or unexported fields }
Response message for creating a product
func (*CreateProductResponse) Descriptor
deprecated
func (*CreateProductResponse) Descriptor() ([]byte, []int)
Deprecated: Use CreateProductResponse.ProtoReflect.Descriptor instead.
func (*CreateProductResponse) GetProduct ¶
func (x *CreateProductResponse) GetProduct() *Product
func (*CreateProductResponse) ProtoMessage ¶
func (*CreateProductResponse) ProtoMessage()
func (*CreateProductResponse) ProtoReflect ¶
func (x *CreateProductResponse) ProtoReflect() protoreflect.Message
func (*CreateProductResponse) Reset ¶
func (x *CreateProductResponse) Reset()
func (*CreateProductResponse) String ¶
func (x *CreateProductResponse) String() string
type Order ¶
type Order struct { Id int32 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` ProductId string `protobuf:"bytes,2,opt,name=product_id,json=productId,proto3" json:"product_id,omitempty"` // contains filtered or unexported fields }
Product message with tags as repeated field
func (*Order) Descriptor
deprecated
func (*Order) GetProductId ¶
func (*Order) ProtoMessage ¶
func (*Order) ProtoMessage()
func (*Order) ProtoReflect ¶
func (x *Order) ProtoReflect() protoreflect.Message
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"` Description string `protobuf:"bytes,3,opt,name=description,proto3" json:"description,omitempty"` Category string `protobuf:"bytes,4,opt,name=category,proto3" json:"category,omitempty"` // category is digital, physical, or service Price int64 `protobuf:"varint,5,opt,name=price,proto3" json:"price,omitempty"` Status ProductStatus `protobuf:"varint,6,opt,name=status,proto3,enum=com.ecommerce.api.v1.ProductStatus" json:"status,omitempty"` Tags []string `protobuf:"bytes,7,rep,name=tags,proto3" json:"tags,omitempty"` // Add tags as repeated field // contains filtered or unexported fields }
Product message with tags as repeated field
func (*Product) Descriptor
deprecated
func (*Product) GetCategory ¶
func (*Product) GetDescription ¶
func (*Product) GetStatus ¶
func (x *Product) GetStatus() ProductStatus
func (*Product) ProtoMessage ¶
func (*Product) ProtoMessage()
func (*Product) ProtoReflect ¶
func (x *Product) ProtoReflect() protoreflect.Message
type ProductServiceClient ¶
type ProductServiceClient interface { // POST /api/v1/products CreateProduct(ctx context.Context, in *CreateProductRequest, opts ...grpc.CallOption) (*CreateProductResponse, 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.
Service definition for ProductService
func NewProductServiceClient ¶
func NewProductServiceClient(cc grpc.ClientConnInterface) ProductServiceClient
type ProductServiceServer ¶
type ProductServiceServer interface { // POST /api/v1/products CreateProduct(context.Context, *CreateProductRequest) (*CreateProductResponse, error) // contains filtered or unexported methods }
ProductServiceServer is the server API for ProductService service. All implementations must embed UnimplementedProductServiceServer for forward compatibility.
Service definition for ProductService
type ProductStatus ¶
type ProductStatus int32
const ( // ACTIVE means the product is available for purchase ProductStatus_ACTIVE ProductStatus = 0 ProductStatus_INACTIVE ProductStatus = 1 )
func (ProductStatus) Descriptor ¶
func (ProductStatus) Descriptor() protoreflect.EnumDescriptor
func (ProductStatus) Enum ¶
func (x ProductStatus) Enum() *ProductStatus
func (ProductStatus) EnumDescriptor
deprecated
func (ProductStatus) EnumDescriptor() ([]byte, []int)
Deprecated: Use ProductStatus.Descriptor instead.
func (ProductStatus) Number ¶
func (x ProductStatus) Number() protoreflect.EnumNumber
func (ProductStatus) String ¶
func (x ProductStatus) String() string
func (ProductStatus) Type ¶
func (ProductStatus) Type() protoreflect.EnumType
type ProductStock ¶
type ProductStock struct { Id int32 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` ProductId string `protobuf:"bytes,2,opt,name=product_id,json=productId,proto3" json:"product_id,omitempty"` Location string `protobuf:"bytes,3,opt,name=location,proto3" json:"location,omitempty"` Status ProductStockStatus `protobuf:"varint,4,opt,name=status,proto3,enum=com.ecommerce.api.v1.ProductStockStatus" json:"status,omitempty"` // contains filtered or unexported fields }
func (*ProductStock) Descriptor
deprecated
func (*ProductStock) Descriptor() ([]byte, []int)
Deprecated: Use ProductStock.ProtoReflect.Descriptor instead.
func (*ProductStock) GetId ¶
func (x *ProductStock) GetId() int32
func (*ProductStock) GetLocation ¶
func (x *ProductStock) GetLocation() string
func (*ProductStock) GetProductId ¶
func (x *ProductStock) GetProductId() string
func (*ProductStock) GetStatus ¶
func (x *ProductStock) GetStatus() ProductStockStatus
func (*ProductStock) ProtoMessage ¶
func (*ProductStock) ProtoMessage()
func (*ProductStock) ProtoReflect ¶
func (x *ProductStock) ProtoReflect() protoreflect.Message
func (*ProductStock) Reset ¶
func (x *ProductStock) Reset()
func (*ProductStock) String ¶
func (x *ProductStock) String() string
type ProductStockStatus ¶
type ProductStockStatus int32
const ( // AVAILABLE means the product is available for purchase ProductStockStatus_AVAILABLE ProductStockStatus = 0 ProductStockStatus_RESERVED ProductStockStatus = 1 ProductStockStatus_SOLD ProductStockStatus = 2 )
func (ProductStockStatus) Descriptor ¶
func (ProductStockStatus) Descriptor() protoreflect.EnumDescriptor
func (ProductStockStatus) Enum ¶
func (x ProductStockStatus) Enum() *ProductStockStatus
func (ProductStockStatus) EnumDescriptor
deprecated
func (ProductStockStatus) EnumDescriptor() ([]byte, []int)
Deprecated: Use ProductStockStatus.Descriptor instead.
func (ProductStockStatus) Number ¶
func (x ProductStockStatus) Number() protoreflect.EnumNumber
func (ProductStockStatus) String ¶
func (x ProductStockStatus) String() string
func (ProductStockStatus) Type ¶
func (ProductStockStatus) Type() protoreflect.EnumType
type UnimplementedProductServiceServer ¶
type UnimplementedProductServiceServer struct{}
UnimplementedProductServiceServer must be embedded to have forward compatible implementations.
NOTE: this should be embedded by value instead of pointer to avoid a nil pointer dereference when methods are called.
func (UnimplementedProductServiceServer) CreateProduct ¶
func (UnimplementedProductServiceServer) CreateProduct(context.Context, *CreateProductRequest) (*CreateProductResponse, error)
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.