pb

package
v0.0.0-...-6796344 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2024 License: MIT Imports: 18 Imported by: 0

Documentation

Overview

Package pb is a reverse proxy.

It translates gRPC into RESTful JSON APIs.

Index

Constants

View Source
const (
	ProductService_CreateProduct_FullMethodName = "/com.ecommerce.api.v1.ProductService/CreateProduct"
)

Variables

View Source
var (
	ProductStatus_name = map[int32]string{
		0: "ACTIVE",
		1: "INACTIVE",
	}
	ProductStatus_value = map[string]int32{
		"ACTIVE":   0,
		"INACTIVE": 1,
	}
)

Enum value maps for ProductStatus.

View Source
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.

View Source
var File_document_proto protoreflect.FileDescriptor
View Source
var File_order_proto protoreflect.FileDescriptor
View Source
var File_product_proto protoreflect.FileDescriptor
View Source
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) Descriptor() ([]byte, []int)

Deprecated: Use Order.ProtoReflect.Descriptor instead.

func (*Order) GetId

func (x *Order) GetId() int32

func (*Order) GetProductId

func (x *Order) GetProductId() string

func (*Order) ProtoMessage

func (*Order) ProtoMessage()

func (*Order) ProtoReflect

func (x *Order) ProtoReflect() protoreflect.Message

func (*Order) Reset

func (x *Order) Reset()

func (*Order) String

func (x *Order) 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"`
	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) Descriptor() ([]byte, []int)

Deprecated: Use Product.ProtoReflect.Descriptor instead.

func (*Product) GetCategory

func (x *Product) GetCategory() string

func (*Product) GetDescription

func (x *Product) GetDescription() string

func (*Product) GetId

func (x *Product) GetId() string

func (*Product) GetName

func (x *Product) GetName() string

func (*Product) GetPrice

func (x *Product) GetPrice() int64

func (*Product) GetStatus

func (x *Product) GetStatus() ProductStatus

func (*Product) GetTags

func (x *Product) GetTags() []string

func (*Product) ProtoMessage

func (*Product) ProtoMessage()

func (*Product) ProtoReflect

func (x *Product) ProtoReflect() protoreflect.Message

func (*Product) Reset

func (x *Product) Reset()

func (*Product) String

func (x *Product) String() string

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

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) Enum

func (x ProductStatus) Enum() *ProductStatus

func (ProductStatus) EnumDescriptor deprecated

func (ProductStatus) EnumDescriptor() ([]byte, []int)

Deprecated: Use ProductStatus.Descriptor instead.

func (ProductStatus) Number

func (ProductStatus) String

func (x ProductStatus) String() string

func (ProductStatus) Type

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) Enum

func (ProductStockStatus) EnumDescriptor deprecated

func (ProductStockStatus) EnumDescriptor() ([]byte, []int)

Deprecated: Use ProductStockStatus.Descriptor instead.

func (ProductStockStatus) Number

func (ProductStockStatus) String

func (x ProductStockStatus) String() string

func (ProductStockStatus) Type

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

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.

Jump to

Keyboard shortcuts

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