Documentation ¶
Overview ¶
Package purchase is a reverse proxy.
It translates gRPC into RESTful JSON APIs.
Index ¶
- Variables
- func Create(ctx context.Context, items []*Purchase, db *mongo.Database) error
- func Delete(ctx context.Context, user string, items []*Purchase, 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 []*Purchase, ...) error
- type Empty
- type Money
- type Purchase
- func (*Purchase) Descriptor() ([]byte, []int)deprecated
- func (x *Purchase) GetId() string
- func (x *Purchase) GetPrice() *Money
- func (x *Purchase) GetProduct() *product.Product
- func (x *Purchase) GetQty() int64
- func (x *Purchase) GetRecordInfo() *record.Info
- func (x *Purchase) GetShop() *shop.Shop
- func (x *Purchase) GetUrl() string
- func (x *Purchase) GetWeight() *Weight
- func (*Purchase) ProtoMessage()
- func (x *Purchase) ProtoReflect() protoreflect.Message
- func (x *Purchase) Reset()
- func (x *Purchase) String() string
- type Request
- func (*Request) Descriptor() ([]byte, []int)deprecated
- func (x *Request) GetId() string
- func (x *Request) GetPayload() []*Purchase
- 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)
- type Weight
Constants ¶
This section is empty.
Variables ¶
var File_purchase_purchase_proto protoreflect.FileDescriptor
var File_purchase_purchaseservice_proto protoreflect.FileDescriptor
Functions ¶
func Create ¶
Create will validate fields for the provided records and attempt to create new Purchase 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 Money ¶
type Money struct { // The 3-letter currency code defined in ISO 4217. CurrencyCode string `protobuf:"bytes,1,opt,name=currency_code,json=currencyCode,proto3" json:"currency_code,omitempty"` Amount float64 `protobuf:"fixed64,2,opt,name=amount,proto3" json:"amount,omitempty"` // contains filtered or unexported fields }
func (*Money) Descriptor
deprecated
func (*Money) GetCurrencyCode ¶
func (*Money) ProtoMessage ¶
func (*Money) ProtoMessage()
func (*Money) ProtoReflect ¶
func (x *Money) ProtoReflect() protoreflect.Message
type Purchase ¶
type Purchase 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"` Shop *shop.Shop `protobuf:"bytes,3,opt,name=shop,proto3" json:"shop,omitempty"` Product *product.Product `protobuf:"bytes,4,opt,name=product,proto3" json:"product,omitempty"` Qty int64 `protobuf:"varint,5,opt,name=qty,proto3" json:"qty,omitempty"` Weight *Weight `protobuf:"bytes,6,opt,name=weight,proto3" json:"weight,omitempty"` Price *Money `protobuf:"bytes,7,opt,name=price,proto3" json:"price,omitempty"` Url string `protobuf:"bytes,8,opt,name=url,proto3" json:"url,omitempty"` // contains filtered or unexported fields }
func RetrieveOne ¶
RetrieveOne ...
func (*Purchase) Descriptor
deprecated
func (*Purchase) GetProduct ¶
func (*Purchase) GetRecordInfo ¶
func (*Purchase) ProtoMessage ¶
func (*Purchase) ProtoMessage()
func (*Purchase) ProtoReflect ¶
func (x *Purchase) 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 Purchase Id string `protobuf:"bytes,3,opt,name=id,proto3" json:"id,omitempty" bson:"_id"` // dataset to process Payload []*Purchase `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 []*Purchase `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 Purchase item(s) Create(ctx context.Context, in *Request, opts ...grpc.CallOption) (*Empty, error) // retrieve a list of Purchase items Retrieve(ctx context.Context, in *Request, opts ...grpc.CallOption) (*Response, error) // update Purchase item(s) Update(ctx context.Context, in *Request, opts ...grpc.CallOption) (*Response, error) // delete Purchase 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 Purchase item(s) Create(context.Context, *Request) (*Empty, error) // retrieve a list of Purchase items Retrieve(context.Context, *Request) (*Response, error) // update Purchase item(s) Update(context.Context, *Request) (*Response, error) // delete Purchase 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
type UnimplementedServiceServer ¶
type UnimplementedServiceServer struct { }
UnimplementedServiceServer can be embedded to have forward compatible implementations.
type Weight ¶
type Weight struct { Unit string `protobuf:"bytes,1,opt,name=unit,proto3" json:"unit,omitempty"` Amount float64 `protobuf:"fixed64,2,opt,name=amount,proto3" json:"amount,omitempty"` // contains filtered or unexported fields }
func (*Weight) Descriptor
deprecated
func (*Weight) ProtoMessage ¶
func (*Weight) ProtoMessage()
func (*Weight) ProtoReflect ¶
func (x *Weight) ProtoReflect() protoreflect.Message