Documentation
¶
Overview ¶
Package product is a reverse proxy.
It translates gRPC into RESTful JSON APIs.
Index ¶
- Variables
- func Create(ctx context.Context, items []*Product, db *mongo.Database) error
- func Delete(ctx context.Context, user string, items []*Product, db *mongo.Database) error
- func RegisterServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error
- func RegisterServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client ServiceClient) error
- func RegisterServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, ...) (err error)
- func RegisterServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server ServiceServer) error
- func RegisterServiceServer(s *grpc.Server, srv ServiceServer)
- func Update(ctx context.Context, user string, filter bson.D, items []*Product, ...) error
- type Empty
- type Product
- func (*Product) Descriptor() ([]byte, []int)deprecated
- func (x *Product) GetId() string
- func (x *Product) GetName() string
- func (x *Product) GetRecordInfo() *record.Info
- func (*Product) ProtoMessage()
- func (x *Product) ProtoReflect() protoreflect.Message
- func (x *Product) Reset()
- func (x *Product) String() string
- type Request
- func (*Request) Descriptor() ([]byte, []int)deprecated
- func (x *Request) GetId() string
- func (x *Request) GetPayload() []*Product
- func (x *Request) GetRequestId() string
- func (x *Request) GetUsername() string
- func (*Request) ProtoMessage()
- func (x *Request) ProtoReflect() protoreflect.Message
- func (x *Request) Reset()
- func (x *Request) String() string
- type Response
- type Server
- func (s *Server) Create(ctx context.Context, req *Request) (*Empty, error)
- func (s *Server) Delete(ctx context.Context, req *Request) (*Empty, error)
- func (s *Server) Retrieve(ctx context.Context, req *Request) (*Response, error)
- func (s *Server) Update(ctx context.Context, req *Request) (*Response, error)
- type ServiceClient
- type ServiceServer
- type UnimplementedServiceServer
- func (*UnimplementedServiceServer) Create(context.Context, *Request) (*Empty, error)
- func (*UnimplementedServiceServer) Delete(context.Context, *Request) (*Empty, error)
- func (*UnimplementedServiceServer) Retrieve(context.Context, *Request) (*Response, error)
- func (*UnimplementedServiceServer) Update(context.Context, *Request) (*Response, error)
Constants ¶
This section is empty.
Variables ¶
var File_product_product_proto protoreflect.FileDescriptor
var File_product_productservice_proto protoreflect.FileDescriptor
Functions ¶
func Create ¶
Create will validate fields for the provided records and attempt to create new Product records in the datastore
func RegisterServiceHandler ¶
func RegisterServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error
RegisterServiceHandler registers the http handlers for service Service to "mux". The handlers forward requests to the grpc endpoint over "conn".
func RegisterServiceHandlerClient ¶
func RegisterServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client ServiceClient) error
RegisterServiceHandlerClient registers the http handlers for service Service to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "ServiceClient". Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "ServiceClient" doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in "ServiceClient" to call the correct interceptors.
func RegisterServiceHandlerFromEndpoint ¶
func RegisterServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error)
RegisterServiceHandlerFromEndpoint is same as RegisterServiceHandler but automatically dials to "endpoint" and closes the connection when "ctx" gets done.
func RegisterServiceHandlerServer ¶
func RegisterServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server ServiceServer) error
RegisterServiceHandlerServer registers the http handlers for service Service to "mux". UnaryRPC :call ServiceServer 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 RegisterServiceHandlerFromEndpoint instead.
func RegisterServiceServer ¶
func RegisterServiceServer(s *grpc.Server, srv ServiceServer)
Types ¶
type Empty ¶
type Empty struct { // unique identifier of the original incoming request to help troubleshoot RequestId string `protobuf:"bytes,1,opt,name=request_id,json=requestId,proto3" json:"request_id,omitempty"` // contains filtered or unexported fields }
func (*Empty) Descriptor
deprecated
func (*Empty) GetRequestId ¶
func (*Empty) ProtoMessage ¶
func (*Empty) ProtoMessage()
func (*Empty) ProtoReflect ¶
func (x *Empty) ProtoReflect() protoreflect.Message
type Product ¶
type Product struct { // standard record values RecordInfo *record.Info `protobuf:"bytes,1,opt,name=record_info,json=recordInfo,proto3" json:"record_info,omitempty"` // unique identifier Id string `protobuf:"bytes,2,opt,name=id,proto3" json:"id,omitempty" bson:"_id"` // name given to the product Name string `protobuf:"bytes,3,opt,name=name,proto3" json:"name,omitempty"` // contains filtered or unexported fields }
func RetrieveOne ¶
RetrieveOne ...
func (*Product) Descriptor
deprecated
func (*Product) GetRecordInfo ¶
func (*Product) ProtoMessage ¶
func (*Product) ProtoMessage()
func (*Product) ProtoReflect ¶
func (x *Product) ProtoReflect() protoreflect.Message
type Request ¶
type Request struct { // unique identifier to help troubleshoot each request RequestId string `protobuf:"bytes,1,opt,name=request_id,json=requestId,proto3" json:"request_id,omitempty"` // username of the one making the request Username string `protobuf:"bytes,2,opt,name=username,proto3" json:"username,omitempty"` // unique identifier of the Product Id string `protobuf:"bytes,3,opt,name=id,proto3" json:"id,omitempty" bson:"_id"` // dataset to process Payload []*Product `protobuf:"bytes,4,rep,name=payload,proto3" json:"payload,omitempty"` // contains filtered or unexported fields }
func (*Request) Descriptor
deprecated
func (*Request) GetPayload ¶
func (*Request) GetRequestId ¶
func (*Request) GetUsername ¶
func (*Request) ProtoMessage ¶
func (*Request) ProtoMessage()
func (*Request) ProtoReflect ¶
func (x *Request) ProtoReflect() protoreflect.Message
type Response ¶
type Response struct { // unique identifier of the original incoming request to help troubleshoot RequestId string `protobuf:"bytes,1,opt,name=request_id,json=requestId,proto3" json:"request_id,omitempty"` Payload []*Product `protobuf:"bytes,2,rep,name=payload,proto3" json:"payload,omitempty"` // contains filtered or unexported fields }
func (*Response) Descriptor
deprecated
func (*Response) GetPayload ¶
func (*Response) GetRequestId ¶
func (*Response) ProtoMessage ¶
func (*Response) ProtoMessage()
func (*Response) ProtoReflect ¶
func (x *Response) ProtoReflect() protoreflect.Message
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
type ServiceClient ¶
type ServiceClient interface { // create new Product item(s) Create(ctx context.Context, in *Request, opts ...grpc.CallOption) (*Empty, error) // retrieve a list of Product items Retrieve(ctx context.Context, in *Request, opts ...grpc.CallOption) (*Response, error) // update Product item(s) Update(ctx context.Context, in *Request, opts ...grpc.CallOption) (*Response, error) // delete Product item(s) Delete(ctx context.Context, in *Request, opts ...grpc.CallOption) (*Empty, error) }
ServiceClient is the client API for Service service.
For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
func NewServiceClient ¶
func NewServiceClient(cc grpc.ClientConnInterface) ServiceClient
type ServiceServer ¶
type ServiceServer interface { // create new Product item(s) Create(context.Context, *Request) (*Empty, error) // retrieve a list of Product items Retrieve(context.Context, *Request) (*Response, error) // update Product item(s) Update(context.Context, *Request) (*Response, error) // delete Product item(s) Delete(context.Context, *Request) (*Empty, error) }
ServiceServer is the server API for Service service.
func NewServer ¶
func NewServer(cmp *config.Composition, client *mongo.Client) ServiceServer