shop

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: 26 Imported by: 0

Documentation

Overview

Package shop is a reverse proxy.

It translates gRPC into RESTful JSON APIs.

Index

Constants

This section is empty.

Variables

View Source
var File_shop_shop_proto protoreflect.FileDescriptor
View Source
var File_shop_shopservice_proto protoreflect.FileDescriptor

Functions

func Create

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

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

func Delete

func Delete(ctx context.Context, user string, items []*Shop, 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 []*Shop, 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 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 Shop
	Id string `protobuf:"bytes,3,opt,name=id,proto3" json:"id,omitempty" bson:"_id"`
	// dataset to process
	Payload []*Shop `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() []*Shop

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   []*Shop `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() []*Shop

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 Shop item(s)
	Create(ctx context.Context, in *Request, opts ...grpc.CallOption) (*Empty, error)
	// retrieve a list of Shop items
	Retrieve(ctx context.Context, in *Request, opts ...grpc.CallOption) (*Response, error)
	// update Shop item(s)
	Update(ctx context.Context, in *Request, opts ...grpc.CallOption) (*Response, error)
	// delete Shop 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 Shop item(s)
	Create(context.Context, *Request) (*Empty, error)
	// retrieve a list of Shop items
	Retrieve(context.Context, *Request) (*Response, error)
	// update Shop item(s)
	Update(context.Context, *Request) (*Response, error)
	// delete Shop 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 Shop

type Shop 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 shop
	Name string `protobuf:"bytes,3,opt,name=name,proto3" json:"name,omitempty"`
	// contains filtered or unexported fields
}

func Retrieve

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

Retrieve ...

func RetrieveOne

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

RetrieveOne ...

func (*Shop) Descriptor deprecated

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

Deprecated: Use Shop.ProtoReflect.Descriptor instead.

func (*Shop) GetId

func (x *Shop) GetId() string

func (*Shop) GetName

func (x *Shop) GetName() string

func (*Shop) GetRecordInfo

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

func (*Shop) ProtoMessage

func (*Shop) ProtoMessage()

func (*Shop) ProtoReflect

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

func (*Shop) Reset

func (x *Shop) Reset()

func (*Shop) String

func (x *Shop) String() string

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

Jump to

Keyboard shortcuts

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