purchase

package
v0.0.0-...-beb616a Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2020 License: MIT Imports: 28 Imported by: 0

Documentation

Overview

Package purchase is a reverse proxy.

It translates gRPC into RESTful JSON APIs.

Index

Constants

This section is empty.

Variables

View Source
var File_purchase_purchase_proto protoreflect.FileDescriptor
View Source
var File_purchase_purchaseservice_proto protoreflect.FileDescriptor

Functions

func Create

func Create(ctx context.Context, items []*Purchase, db *mongo.Database) error

Create will validate fields for the provided records and attempt to create new Purchase records in the datastore

func Delete

func Delete(ctx context.Context, user string, items []*Purchase, db *mongo.Database) error

Delete ...

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)

func Update

func Update(ctx context.Context, user string, filter bson.D, items []*Purchase, db *mongo.Database) error

Update ...

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) Descriptor() ([]byte, []int)

Deprecated: Use Empty.ProtoReflect.Descriptor instead.

func (*Empty) GetRequestId

func (x *Empty) GetRequestId() string

func (*Empty) ProtoMessage

func (*Empty) ProtoMessage()

func (*Empty) ProtoReflect

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

func (*Empty) Reset

func (x *Empty) Reset()

func (*Empty) String

func (x *Empty) String() string

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) Descriptor() ([]byte, []int)

Deprecated: Use Money.ProtoReflect.Descriptor instead.

func (*Money) GetAmount

func (x *Money) GetAmount() float64

func (*Money) GetCurrencyCode

func (x *Money) GetCurrencyCode() string

func (*Money) ProtoMessage

func (*Money) ProtoMessage()

func (*Money) ProtoReflect

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

func (*Money) Reset

func (x *Money) Reset()

func (*Money) String

func (x *Money) String() string

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 Retrieve

func Retrieve(ctx context.Context, filter bson.D, db *mongo.Database) ([]*Purchase, error)

Retrieve ...

func RetrieveOne

func RetrieveOne(ctx context.Context, id string, db *mongo.Database) (*Purchase, error)

RetrieveOne ...

func (*Purchase) Descriptor deprecated

func (*Purchase) Descriptor() ([]byte, []int)

Deprecated: Use Purchase.ProtoReflect.Descriptor instead.

func (*Purchase) GetId

func (x *Purchase) GetId() string

func (*Purchase) GetPrice

func (x *Purchase) GetPrice() *Money

func (*Purchase) GetProduct

func (x *Purchase) GetProduct() *product.Product

func (*Purchase) GetQty

func (x *Purchase) GetQty() int64

func (*Purchase) GetRecordInfo

func (x *Purchase) GetRecordInfo() *record.Info

func (*Purchase) GetShop

func (x *Purchase) GetShop() *shop.Shop

func (*Purchase) GetUrl

func (x *Purchase) GetUrl() string

func (*Purchase) GetWeight

func (x *Purchase) GetWeight() *Weight

func (*Purchase) ProtoMessage

func (*Purchase) ProtoMessage()

func (*Purchase) ProtoReflect

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

func (*Purchase) Reset

func (x *Purchase) Reset()

func (*Purchase) String

func (x *Purchase) String() string

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) Descriptor() ([]byte, []int)

Deprecated: Use Request.ProtoReflect.Descriptor instead.

func (*Request) GetId

func (x *Request) GetId() string

func (*Request) GetPayload

func (x *Request) GetPayload() []*Purchase

func (*Request) GetRequestId

func (x *Request) GetRequestId() string

func (*Request) GetUsername

func (x *Request) GetUsername() string

func (*Request) ProtoMessage

func (*Request) ProtoMessage()

func (*Request) ProtoReflect

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

func (*Request) Reset

func (x *Request) Reset()

func (*Request) String

func (x *Request) String() string

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) Descriptor() ([]byte, []int)

Deprecated: Use Response.ProtoReflect.Descriptor instead.

func (*Response) GetPayload

func (x *Response) GetPayload() []*Purchase

func (*Response) GetRequestId

func (x *Response) GetRequestId() string

func (*Response) ProtoMessage

func (*Response) ProtoMessage()

func (*Response) ProtoReflect

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

func (*Response) Reset

func (x *Response) Reset()

func (*Response) String

func (x *Response) String() string

type Server

type Server struct {
	// contains filtered or unexported fields
}

func (*Server) Create

func (s *Server) Create(ctx context.Context, req *Request) (*Empty, error)

func (*Server) Delete

func (s *Server) Delete(ctx context.Context, req *Request) (*Empty, error)

func (*Server) Retrieve

func (s *Server) Retrieve(ctx context.Context, req *Request) (*Response, error)

func (*Server) Update

func (s *Server) Update(ctx context.Context, req *Request) (*Response, error)

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.

func (*UnimplementedServiceServer) Create

func (*UnimplementedServiceServer) Delete

func (*UnimplementedServiceServer) Retrieve

func (*UnimplementedServiceServer) Update

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) Descriptor() ([]byte, []int)

Deprecated: Use Weight.ProtoReflect.Descriptor instead.

func (*Weight) GetAmount

func (x *Weight) GetAmount() float64

func (*Weight) GetUnit

func (x *Weight) GetUnit() string

func (*Weight) ProtoMessage

func (*Weight) ProtoMessage()

func (*Weight) ProtoReflect

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

func (*Weight) Reset

func (x *Weight) Reset()

func (*Weight) String

func (x *Weight) String() string

Jump to

Keyboard shortcuts

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