pull/14/head
Andrey Ivanov 2020-10-07 14:17:35 +03:00 committed by tiburon
parent 9c5086d145
commit 9502e665e2
3 changed files with 959 additions and 0 deletions

1
.gitignore vendored
View File

@ -24,3 +24,4 @@ go-telnet
.Trashes
ehthumbs.db
Thumbs.db
/hw12_13_14_15_calendar/calendar.log

View File

@ -0,0 +1,624 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// source: grpc.proto
package grpc
import (
context "context"
fmt "fmt"
proto "github.com/golang/protobuf/proto"
duration "github.com/golang/protobuf/ptypes/duration"
empty "github.com/golang/protobuf/ptypes/empty"
timestamp "github.com/golang/protobuf/ptypes/timestamp"
_ "google.golang.org/genproto/googleapis/api/annotations"
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
math "math"
)
// Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal
var _ = fmt.Errorf
var _ = math.Inf
// This is a compile-time assertion to ensure that this generated file
// is compatible with the proto package it is being compiled against.
// A compilation error at this line likely means your copy of the
// proto package needs to be updated.
const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package
type QueryRange int32
const (
QueryRange_DAY QueryRange = 0
QueryRange_WEEK QueryRange = 1
QueryRange_MONTH QueryRange = 2
)
var QueryRange_name = map[int32]string{
0: "DAY",
1: "WEEK",
2: "MONTH",
}
var QueryRange_value = map[string]int32{
"DAY": 0,
"WEEK": 1,
"MONTH": 2,
}
func (x QueryRange) String() string {
return proto.EnumName(QueryRange_name, int32(x))
}
func (QueryRange) EnumDescriptor() ([]byte, []int) {
return fileDescriptor_bedfbfc9b54e5600, []int{0}
}
type Event struct {
ID string `protobuf:"bytes,1,opt,name=ID,proto3" json:"ID,omitempty"`
Title string `protobuf:"bytes,2,opt,name=Title,proto3" json:"Title,omitempty"`
Date *timestamp.Timestamp `protobuf:"bytes,3,opt,name=Date,proto3" json:"Date,omitempty"`
Latency *duration.Duration `protobuf:"bytes,4,opt,name=Latency,proto3" json:"Latency,omitempty"`
Note string `protobuf:"bytes,5,opt,name=Note,proto3" json:"Note,omitempty"`
UserID string `protobuf:"bytes,6,opt,name=UserID,proto3" json:"UserID,omitempty"`
NotifyTime *duration.Duration `protobuf:"bytes,7,opt,name=NotifyTime,proto3" json:"NotifyTime,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *Event) Reset() { *m = Event{} }
func (m *Event) String() string { return proto.CompactTextString(m) }
func (*Event) ProtoMessage() {}
func (*Event) Descriptor() ([]byte, []int) {
return fileDescriptor_bedfbfc9b54e5600, []int{0}
}
func (m *Event) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_Event.Unmarshal(m, b)
}
func (m *Event) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_Event.Marshal(b, m, deterministic)
}
func (m *Event) XXX_Merge(src proto.Message) {
xxx_messageInfo_Event.Merge(m, src)
}
func (m *Event) XXX_Size() int {
return xxx_messageInfo_Event.Size(m)
}
func (m *Event) XXX_DiscardUnknown() {
xxx_messageInfo_Event.DiscardUnknown(m)
}
var xxx_messageInfo_Event proto.InternalMessageInfo
func (m *Event) GetID() string {
if m != nil {
return m.ID
}
return ""
}
func (m *Event) GetTitle() string {
if m != nil {
return m.Title
}
return ""
}
func (m *Event) GetDate() *timestamp.Timestamp {
if m != nil {
return m.Date
}
return nil
}
func (m *Event) GetLatency() *duration.Duration {
if m != nil {
return m.Latency
}
return nil
}
func (m *Event) GetNote() string {
if m != nil {
return m.Note
}
return ""
}
func (m *Event) GetUserID() string {
if m != nil {
return m.UserID
}
return ""
}
func (m *Event) GetNotifyTime() *duration.Duration {
if m != nil {
return m.NotifyTime
}
return nil
}
type EventList struct {
Events []*Event `protobuf:"bytes,1,rep,name=Events,proto3" json:"Events,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *EventList) Reset() { *m = EventList{} }
func (m *EventList) String() string { return proto.CompactTextString(m) }
func (*EventList) ProtoMessage() {}
func (*EventList) Descriptor() ([]byte, []int) {
return fileDescriptor_bedfbfc9b54e5600, []int{1}
}
func (m *EventList) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_EventList.Unmarshal(m, b)
}
func (m *EventList) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_EventList.Marshal(b, m, deterministic)
}
func (m *EventList) XXX_Merge(src proto.Message) {
xxx_messageInfo_EventList.Merge(m, src)
}
func (m *EventList) XXX_Size() int {
return xxx_messageInfo_EventList.Size(m)
}
func (m *EventList) XXX_DiscardUnknown() {
xxx_messageInfo_EventList.DiscardUnknown(m)
}
var xxx_messageInfo_EventList proto.InternalMessageInfo
func (m *EventList) GetEvents() []*Event {
if m != nil {
return m.Events
}
return nil
}
type EventID struct {
ID string `protobuf:"bytes,1,opt,name=ID,proto3" json:"ID,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *EventID) Reset() { *m = EventID{} }
func (m *EventID) String() string { return proto.CompactTextString(m) }
func (*EventID) ProtoMessage() {}
func (*EventID) Descriptor() ([]byte, []int) {
return fileDescriptor_bedfbfc9b54e5600, []int{2}
}
func (m *EventID) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_EventID.Unmarshal(m, b)
}
func (m *EventID) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_EventID.Marshal(b, m, deterministic)
}
func (m *EventID) XXX_Merge(src proto.Message) {
xxx_messageInfo_EventID.Merge(m, src)
}
func (m *EventID) XXX_Size() int {
return xxx_messageInfo_EventID.Size(m)
}
func (m *EventID) XXX_DiscardUnknown() {
xxx_messageInfo_EventID.DiscardUnknown(m)
}
var xxx_messageInfo_EventID proto.InternalMessageInfo
func (m *EventID) GetID() string {
if m != nil {
return m.ID
}
return ""
}
type EventWthID struct {
ID string `protobuf:"bytes,1,opt,name=ID,proto3" json:"ID,omitempty"`
Event *Event `protobuf:"bytes,2,opt,name=Event,proto3" json:"Event,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *EventWthID) Reset() { *m = EventWthID{} }
func (m *EventWthID) String() string { return proto.CompactTextString(m) }
func (*EventWthID) ProtoMessage() {}
func (*EventWthID) Descriptor() ([]byte, []int) {
return fileDescriptor_bedfbfc9b54e5600, []int{3}
}
func (m *EventWthID) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_EventWthID.Unmarshal(m, b)
}
func (m *EventWthID) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_EventWthID.Marshal(b, m, deterministic)
}
func (m *EventWthID) XXX_Merge(src proto.Message) {
xxx_messageInfo_EventWthID.Merge(m, src)
}
func (m *EventWthID) XXX_Size() int {
return xxx_messageInfo_EventWthID.Size(m)
}
func (m *EventWthID) XXX_DiscardUnknown() {
xxx_messageInfo_EventWthID.DiscardUnknown(m)
}
var xxx_messageInfo_EventWthID proto.InternalMessageInfo
func (m *EventWthID) GetID() string {
if m != nil {
return m.ID
}
return ""
}
func (m *EventWthID) GetEvent() *Event {
if m != nil {
return m.Event
}
return nil
}
type Date struct {
Date *timestamp.Timestamp `protobuf:"bytes,1,opt,name=Date,proto3" json:"Date,omitempty"`
Range QueryRange `protobuf:"varint,2,opt,name=Range,proto3,enum=QueryRange" json:"Range,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *Date) Reset() { *m = Date{} }
func (m *Date) String() string { return proto.CompactTextString(m) }
func (*Date) ProtoMessage() {}
func (*Date) Descriptor() ([]byte, []int) {
return fileDescriptor_bedfbfc9b54e5600, []int{4}
}
func (m *Date) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_Date.Unmarshal(m, b)
}
func (m *Date) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_Date.Marshal(b, m, deterministic)
}
func (m *Date) XXX_Merge(src proto.Message) {
xxx_messageInfo_Date.Merge(m, src)
}
func (m *Date) XXX_Size() int {
return xxx_messageInfo_Date.Size(m)
}
func (m *Date) XXX_DiscardUnknown() {
xxx_messageInfo_Date.DiscardUnknown(m)
}
var xxx_messageInfo_Date proto.InternalMessageInfo
func (m *Date) GetDate() *timestamp.Timestamp {
if m != nil {
return m.Date
}
return nil
}
func (m *Date) GetRange() QueryRange {
if m != nil {
return m.Range
}
return QueryRange_DAY
}
func init() {
proto.RegisterEnum("QueryRange", QueryRange_name, QueryRange_value)
proto.RegisterType((*Event)(nil), "Event")
proto.RegisterType((*EventList)(nil), "EventList")
proto.RegisterType((*EventID)(nil), "EventID")
proto.RegisterType((*EventWthID)(nil), "EventWthID")
proto.RegisterType((*Date)(nil), "Date")
}
func init() { proto.RegisterFile("grpc.proto", fileDescriptor_bedfbfc9b54e5600) }
var fileDescriptor_bedfbfc9b54e5600 = []byte{
// 516 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x52, 0xcd, 0x6e, 0xd3, 0x4c,
0x14, 0xad, 0x1d, 0xff, 0x24, 0x37, 0xfa, 0xf2, 0x85, 0x2b, 0x54, 0x5c, 0x53, 0x95, 0xe0, 0x0d,
0x51, 0x90, 0xc6, 0x52, 0xba, 0x40, 0xcd, 0x06, 0x01, 0x13, 0x81, 0x45, 0x09, 0xc2, 0x4a, 0x55,
0x75, 0xe9, 0xb6, 0xd3, 0x60, 0x29, 0xb1, 0x2d, 0x67, 0x82, 0x14, 0x45, 0xd9, 0xf0, 0x0a, 0xbc,
0x18, 0x12, 0xaf, 0xc0, 0x4b, 0xb0, 0x43, 0xbe, 0x9e, 0xfc, 0x90, 0xa8, 0x82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0x5e, 0xbd, 0x06, 0x49, 0xab, 0x68, 0xf9, 0x82, 0x9e, 0x39, 0x03, 0xfb, 0xad, 0x90, 0xaf, 0xe7,
0x01, 0xdf, 0xf2, 0xdd, 0x16, 0x28, 0x2f, 0x54, 0x5e, 0x2f, 0xa0, 0x46, 0x7c, 0x4a, 0xdd, 0x64,
0xc5, 0xe7, 0x0f, 0xfa, 0x23, 0xa2, 0x3f, 0xc0, 0xff, 0xfd, 0x45, 0x81, 0x2d, 0xfd, 0x05, 0xe5,
0xbd, 0xbc, 0xb6, 0x68, 0xa8, 0xd3, 0xdf, 0x01, 0x00, 0x00, 0xff, 0xff, 0xcc, 0x6d, 0x1a, 0xc6,
0xea, 0x03, 0x00, 0x00,
}
// Reference imports to suppress errors if they are not otherwise used.
var _ context.Context
var _ grpc.ClientConn
// This is a compile-time assertion to ensure that this generated file
// is compatible with the grpc package it is being compiled against.
const _ = grpc.SupportPackageIsVersion4
// GrpcClient is the client API for Grpc service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
type GrpcClient interface {
Create(ctx context.Context, in *Event, opts ...grpc.CallOption) (*EventID, error)
Update(ctx context.Context, in *EventWthID, opts ...grpc.CallOption) (*empty.Empty, error)
Delete(ctx context.Context, in *EventID, opts ...grpc.CallOption) (*empty.Empty, error)
List(ctx context.Context, in *empty.Empty, opts ...grpc.CallOption) (*EventList, error)
GetByID(ctx context.Context, in *EventID, opts ...grpc.CallOption) (*EventList, error)
GetByDate(ctx context.Context, in *Date, opts ...grpc.CallOption) (*EventList, error)
}
type grpcClient struct {
cc *grpc.ClientConn
}
func NewGrpcClient(cc *grpc.ClientConn) GrpcClient {
return &grpcClient{cc}
}
func (c *grpcClient) Create(ctx context.Context, in *Event, opts ...grpc.CallOption) (*EventID, error) {
out := new(EventID)
err := c.cc.Invoke(ctx, "/grpc/Create", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *grpcClient) Update(ctx context.Context, in *EventWthID, opts ...grpc.CallOption) (*empty.Empty, error) {
out := new(empty.Empty)
err := c.cc.Invoke(ctx, "/grpc/Update", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *grpcClient) Delete(ctx context.Context, in *EventID, opts ...grpc.CallOption) (*empty.Empty, error) {
out := new(empty.Empty)
err := c.cc.Invoke(ctx, "/grpc/Delete", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *grpcClient) List(ctx context.Context, in *empty.Empty, opts ...grpc.CallOption) (*EventList, error) {
out := new(EventList)
err := c.cc.Invoke(ctx, "/grpc/List", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *grpcClient) GetByID(ctx context.Context, in *EventID, opts ...grpc.CallOption) (*EventList, error) {
out := new(EventList)
err := c.cc.Invoke(ctx, "/grpc/GetByID", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *grpcClient) GetByDate(ctx context.Context, in *Date, opts ...grpc.CallOption) (*EventList, error) {
out := new(EventList)
err := c.cc.Invoke(ctx, "/grpc/GetByDate", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// GrpcServer is the server API for Grpc service.
type GrpcServer interface {
Create(context.Context, *Event) (*EventID, error)
Update(context.Context, *EventWthID) (*empty.Empty, error)
Delete(context.Context, *EventID) (*empty.Empty, error)
List(context.Context, *empty.Empty) (*EventList, error)
GetByID(context.Context, *EventID) (*EventList, error)
GetByDate(context.Context, *Date) (*EventList, error)
}
// UnimplementedGrpcServer can be embedded to have forward compatible implementations.
type UnimplementedGrpcServer struct {
}
func (*UnimplementedGrpcServer) Create(ctx context.Context, req *Event) (*EventID, error) {
return nil, status.Errorf(codes.Unimplemented, "method Create not implemented")
}
func (*UnimplementedGrpcServer) Update(ctx context.Context, req *EventWthID) (*empty.Empty, error) {
return nil, status.Errorf(codes.Unimplemented, "method Update not implemented")
}
func (*UnimplementedGrpcServer) Delete(ctx context.Context, req *EventID) (*empty.Empty, error) {
return nil, status.Errorf(codes.Unimplemented, "method Delete not implemented")
}
func (*UnimplementedGrpcServer) List(ctx context.Context, req *empty.Empty) (*EventList, error) {
return nil, status.Errorf(codes.Unimplemented, "method List not implemented")
}
func (*UnimplementedGrpcServer) GetByID(ctx context.Context, req *EventID) (*EventList, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetByID not implemented")
}
func (*UnimplementedGrpcServer) GetByDate(ctx context.Context, req *Date) (*EventList, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetByDate not implemented")
}
func RegisterGrpcServer(s *grpc.Server, srv GrpcServer) {
s.RegisterService(&_Grpc_serviceDesc, srv)
}
func _Grpc_Create_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(Event)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(GrpcServer).Create(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/grpc/Create",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(GrpcServer).Create(ctx, req.(*Event))
}
return interceptor(ctx, in, info, handler)
}
func _Grpc_Update_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(EventWthID)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(GrpcServer).Update(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/grpc/Update",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(GrpcServer).Update(ctx, req.(*EventWthID))
}
return interceptor(ctx, in, info, handler)
}
func _Grpc_Delete_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(EventID)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(GrpcServer).Delete(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/grpc/Delete",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(GrpcServer).Delete(ctx, req.(*EventID))
}
return interceptor(ctx, in, info, handler)
}
func _Grpc_List_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(empty.Empty)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(GrpcServer).List(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/grpc/List",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(GrpcServer).List(ctx, req.(*empty.Empty))
}
return interceptor(ctx, in, info, handler)
}
func _Grpc_GetByID_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(EventID)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(GrpcServer).GetByID(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/grpc/GetByID",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(GrpcServer).GetByID(ctx, req.(*EventID))
}
return interceptor(ctx, in, info, handler)
}
func _Grpc_GetByDate_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(Date)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(GrpcServer).GetByDate(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/grpc/GetByDate",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(GrpcServer).GetByDate(ctx, req.(*Date))
}
return interceptor(ctx, in, info, handler)
}
var _Grpc_serviceDesc = grpc.ServiceDesc{
ServiceName: "grpc",
HandlerType: (*GrpcServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "Create",
Handler: _Grpc_Create_Handler,
},
{
MethodName: "Update",
Handler: _Grpc_Update_Handler,
},
{
MethodName: "Delete",
Handler: _Grpc_Delete_Handler,
},
{
MethodName: "List",
Handler: _Grpc_List_Handler,
},
{
MethodName: "GetByID",
Handler: _Grpc_GetByID_Handler,
},
{
MethodName: "GetByDate",
Handler: _Grpc_GetByDate_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "grpc.proto",
}

View File

@ -0,0 +1,334 @@
// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT.
// source: grpc.proto
/*
Package grpc is a reverse proxy.
It translates gRPC into RESTful JSON APIs.
*/
package grpc
import (
"io"
"net/http"
"github.com/golang/protobuf/proto"
"github.com/golang/protobuf/ptypes/empty"
"github.com/grpc-ecosystem/grpc-gateway/runtime"
"github.com/grpc-ecosystem/grpc-gateway/utilities"
"golang.org/x/net/context"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/grpclog"
"google.golang.org/grpc/status"
)
var _ codes.Code
var _ io.Reader
var _ status.Status
var _ = runtime.String
var _ = utilities.NewDoubleArray
func request_Grpc_Update_0(ctx context.Context, marshaler runtime.Marshaler, client GrpcClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq EventWthID
var metadata runtime.ServerMetadata
newReader, berr := utilities.IOReaderFactory(req.Body)
if berr != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr)
}
if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
var (
val string
ok bool
err error
_ = err
)
val, ok = pathParams["ID"]
if !ok {
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "ID")
}
protoReq.ID, err = runtime.String(val)
if err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "ID", err)
}
msg, err := client.Update(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func request_Grpc_Delete_0(ctx context.Context, marshaler runtime.Marshaler, client GrpcClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq EventID
var metadata runtime.ServerMetadata
var (
val string
ok bool
err error
_ = err
)
val, ok = pathParams["ID"]
if !ok {
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "ID")
}
protoReq.ID, err = runtime.String(val)
if err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "ID", err)
}
msg, err := client.Delete(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func request_Grpc_List_0(ctx context.Context, marshaler runtime.Marshaler, client GrpcClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq empty.Empty
var metadata runtime.ServerMetadata
msg, err := client.List(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func request_Grpc_GetByID_0(ctx context.Context, marshaler runtime.Marshaler, client GrpcClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq EventID
var metadata runtime.ServerMetadata
var (
val string
ok bool
err error
_ = err
)
val, ok = pathParams["ID"]
if !ok {
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "ID")
}
protoReq.ID, err = runtime.String(val)
if err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "ID", err)
}
msg, err := client.GetByID(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func request_Grpc_GetByDate_0(ctx context.Context, marshaler runtime.Marshaler, client GrpcClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq Date
var metadata runtime.ServerMetadata
var (
val string
e int32
ok bool
err error
_ = err
)
val, ok = pathParams["Date"]
if !ok {
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "Date")
}
protoReq.Date, err = runtime.Timestamp(val)
if err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "Date", err)
}
val, ok = pathParams["Range"]
if !ok {
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "Range")
}
e, err = runtime.Enum(val, QueryRange_value)
if err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "Range", err)
}
protoReq.Range = QueryRange(e)
msg, err := client.GetByDate(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
// RegisterGrpcHandlerFromEndpoint is same as RegisterGrpcHandler but
// automatically dials to "endpoint" and closes the connection when "ctx" gets done.
func RegisterGrpcHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) {
conn, err := grpc.Dial(endpoint, opts...)
if err != nil {
return err
}
defer func() {
if err != nil {
if cerr := conn.Close(); cerr != nil {
grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr)
}
return
}
go func() {
<-ctx.Done()
if cerr := conn.Close(); cerr != nil {
grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr)
}
}()
}()
return RegisterGrpcHandler(ctx, mux, conn)
}
// RegisterGrpcHandler registers the http handlers for service Grpc to "mux".
// The handlers forward requests to the grpc endpoint over "conn".
func RegisterGrpcHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error {
return RegisterGrpcHandlerClient(ctx, mux, NewGrpcClient(conn))
}
// RegisterGrpcHandlerClient registers the http handlers for service Grpc
// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "GrpcClient".
// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "GrpcClient"
// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in
// "GrpcClient" to call the correct interceptors.
func RegisterGrpcHandlerClient(ctx context.Context, mux *runtime.ServeMux, client GrpcClient) error {
mux.Handle("PUT", pattern_Grpc_Update_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
rctx, err := runtime.AnnotateContext(ctx, mux, req)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := request_Grpc_Update_0(rctx, inboundMarshaler, client, req, pathParams)
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
forward_Grpc_Update_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("DELETE", pattern_Grpc_Delete_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
rctx, err := runtime.AnnotateContext(ctx, mux, req)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := request_Grpc_Delete_0(rctx, inboundMarshaler, client, req, pathParams)
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
forward_Grpc_Delete_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("GET", pattern_Grpc_List_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
rctx, err := runtime.AnnotateContext(ctx, mux, req)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := request_Grpc_List_0(rctx, inboundMarshaler, client, req, pathParams)
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
forward_Grpc_List_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("GET", pattern_Grpc_GetByID_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
rctx, err := runtime.AnnotateContext(ctx, mux, req)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := request_Grpc_GetByID_0(rctx, inboundMarshaler, client, req, pathParams)
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
forward_Grpc_GetByID_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("GET", pattern_Grpc_GetByDate_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
rctx, err := runtime.AnnotateContext(ctx, mux, req)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := request_Grpc_GetByDate_0(rctx, inboundMarshaler, client, req, pathParams)
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
forward_Grpc_GetByDate_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
return nil
}
var (
pattern_Grpc_Update_0 = runtime.MustPattern(runtime.NewPattern(1, []int{1, 0, 4, 1, 5, 0}, []string{"ID"}, ""))
pattern_Grpc_Delete_0 = runtime.MustPattern(runtime.NewPattern(1, []int{1, 0, 4, 1, 5, 0}, []string{"ID"}, ""))
pattern_Grpc_List_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0}, []string{"event"}, ""))
pattern_Grpc_GetByID_0 = runtime.MustPattern(runtime.NewPattern(1, []int{1, 0, 4, 1, 5, 0}, []string{"ID"}, ""))
pattern_Grpc_GetByDate_0 = runtime.MustPattern(runtime.NewPattern(1, []int{1, 0, 4, 1, 5, 0, 1, 0, 4, 1, 5, 1}, []string{"Date", "Range"}, ""))
)
var (
forward_Grpc_Update_0 = runtime.ForwardResponseMessage
forward_Grpc_Delete_0 = runtime.ForwardResponseMessage
forward_Grpc_List_0 = runtime.ForwardResponseMessage
forward_Grpc_GetByID_0 = runtime.ForwardResponseMessage
forward_Grpc_GetByDate_0 = runtime.ForwardResponseMessage
)