First commit. Modified proto. Added empty handler method.

This commit is contained in:
Milos Gajdos 2019-11-26 15:39:55 +00:00
parent 6f1c30aef5
commit 4e965e4ce5
No known key found for this signature in database
GPG Key ID: 8B31058CC55DFD4F
4 changed files with 243 additions and 32 deletions

View File

@ -39,3 +39,7 @@ func (d *Debug) Stats(ctx context.Context, req *proto.StatsRequest, rsp *proto.S
rsp.Threads = uint64(runtime.NumGoroutine())
return nil
}
func (d *Debug) Log(ctx context.Context, req *proto.LogRequest, rsp *proto.Debug_LogStream) error {
return nil
}

View File

@ -1,5 +1,5 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// source: github.com/micro/go-micro/debug/proto/debug.proto
// source: debug.proto
package debug
@ -30,7 +30,7 @@ func (m *HealthRequest) Reset() { *m = HealthRequest{} }
func (m *HealthRequest) String() string { return proto.CompactTextString(m) }
func (*HealthRequest) ProtoMessage() {}
func (*HealthRequest) Descriptor() ([]byte, []int) {
return fileDescriptor_7cb19b1a05a6e0a9, []int{0}
return fileDescriptor_8d9d361be58531fb, []int{0}
}
func (m *HealthRequest) XXX_Unmarshal(b []byte) error {
@ -63,7 +63,7 @@ func (m *HealthResponse) Reset() { *m = HealthResponse{} }
func (m *HealthResponse) String() string { return proto.CompactTextString(m) }
func (*HealthResponse) ProtoMessage() {}
func (*HealthResponse) Descriptor() ([]byte, []int) {
return fileDescriptor_7cb19b1a05a6e0a9, []int{1}
return fileDescriptor_8d9d361be58531fb, []int{1}
}
func (m *HealthResponse) XXX_Unmarshal(b []byte) error {
@ -101,7 +101,7 @@ func (m *StatsRequest) Reset() { *m = StatsRequest{} }
func (m *StatsRequest) String() string { return proto.CompactTextString(m) }
func (*StatsRequest) ProtoMessage() {}
func (*StatsRequest) Descriptor() ([]byte, []int) {
return fileDescriptor_7cb19b1a05a6e0a9, []int{2}
return fileDescriptor_8d9d361be58531fb, []int{2}
}
func (m *StatsRequest) XXX_Unmarshal(b []byte) error {
@ -142,7 +142,7 @@ func (m *StatsResponse) Reset() { *m = StatsResponse{} }
func (m *StatsResponse) String() string { return proto.CompactTextString(m) }
func (*StatsResponse) ProtoMessage() {}
func (*StatsResponse) Descriptor() ([]byte, []int) {
return fileDescriptor_7cb19b1a05a6e0a9, []int{3}
return fileDescriptor_8d9d361be58531fb, []int{3}
}
func (m *StatsResponse) XXX_Unmarshal(b []byte) error {
@ -198,32 +198,139 @@ func (m *StatsResponse) GetGc() uint64 {
return 0
}
// LogRequest queries service for logs
type LogRequest struct {
// count is the count of events
Count uint64 `protobuf:"varint,1,opt,name=count,proto3" json:"count,omitempty"`
// relative time in seconds
// before the current time
// from which to show logs
Since uint64 `protobuf:"varint,2,opt,name=since,proto3" json:"since,omitempty"`
// stream logs continuously
Stream bool `protobuf:"varint,3,opt,name=stream,proto3" json:"stream,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *LogRequest) Reset() { *m = LogRequest{} }
func (m *LogRequest) String() string { return proto.CompactTextString(m) }
func (*LogRequest) ProtoMessage() {}
func (*LogRequest) Descriptor() ([]byte, []int) {
return fileDescriptor_8d9d361be58531fb, []int{4}
}
func (m *LogRequest) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_LogRequest.Unmarshal(m, b)
}
func (m *LogRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_LogRequest.Marshal(b, m, deterministic)
}
func (m *LogRequest) XXX_Merge(src proto.Message) {
xxx_messageInfo_LogRequest.Merge(m, src)
}
func (m *LogRequest) XXX_Size() int {
return xxx_messageInfo_LogRequest.Size(m)
}
func (m *LogRequest) XXX_DiscardUnknown() {
xxx_messageInfo_LogRequest.DiscardUnknown(m)
}
var xxx_messageInfo_LogRequest proto.InternalMessageInfo
func (m *LogRequest) GetCount() uint64 {
if m != nil {
return m.Count
}
return 0
}
func (m *LogRequest) GetSince() uint64 {
if m != nil {
return m.Since
}
return 0
}
func (m *LogRequest) GetStream() bool {
if m != nil {
return m.Stream
}
return false
}
// LogEvent is service log event
type LogEvent struct {
// event log record
// TODO: change this
Record string `protobuf:"bytes,1,opt,name=record,proto3" json:"record,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *LogEvent) Reset() { *m = LogEvent{} }
func (m *LogEvent) String() string { return proto.CompactTextString(m) }
func (*LogEvent) ProtoMessage() {}
func (*LogEvent) Descriptor() ([]byte, []int) {
return fileDescriptor_8d9d361be58531fb, []int{5}
}
func (m *LogEvent) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_LogEvent.Unmarshal(m, b)
}
func (m *LogEvent) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_LogEvent.Marshal(b, m, deterministic)
}
func (m *LogEvent) XXX_Merge(src proto.Message) {
xxx_messageInfo_LogEvent.Merge(m, src)
}
func (m *LogEvent) XXX_Size() int {
return xxx_messageInfo_LogEvent.Size(m)
}
func (m *LogEvent) XXX_DiscardUnknown() {
xxx_messageInfo_LogEvent.DiscardUnknown(m)
}
var xxx_messageInfo_LogEvent proto.InternalMessageInfo
func (m *LogEvent) GetRecord() string {
if m != nil {
return m.Record
}
return ""
}
func init() {
proto.RegisterType((*HealthRequest)(nil), "HealthRequest")
proto.RegisterType((*HealthResponse)(nil), "HealthResponse")
proto.RegisterType((*StatsRequest)(nil), "StatsRequest")
proto.RegisterType((*StatsResponse)(nil), "StatsResponse")
proto.RegisterType((*LogRequest)(nil), "LogRequest")
proto.RegisterType((*LogEvent)(nil), "LogEvent")
}
func init() {
proto.RegisterFile("github.com/micro/go-micro/debug/proto/debug.proto", fileDescriptor_7cb19b1a05a6e0a9)
}
func init() { proto.RegisterFile("debug.proto", fileDescriptor_8d9d361be58531fb) }
var fileDescriptor_7cb19b1a05a6e0a9 = []byte{
// 237 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x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0xf4, 0x01,
0xaa, 0x04, 0x42, 0x89, 0xd8, 0x21, 0x5e, 0xce, 0x62, 0x4f, 0xc8, 0x0f, 0xb4, 0x81, 0x32, 0x7e,
0x9d, 0xd6, 0xe2, 0x3f, 0xd3, 0x85, 0x88, 0x1d, 0x11, 0x3f, 0xf4, 0x55, 0xbc, 0xdb, 0xcb, 0x5f,
0x00, 0x00, 0x00, 0xff, 0xff, 0x20, 0xb8, 0xfe, 0x98, 0x6c, 0x01, 0x00, 0x00,
var fileDescriptor_8d9d361be58531fb = []byte{
// 290 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x54, 0x91, 0xdd, 0x4a, 0xc3, 0x30,
0x14, 0xc7, 0xd7, 0x6d, 0x9d, 0xdb, 0x99, 0xeb, 0x20, 0x88, 0x84, 0x5d, 0x69, 0xae, 0x06, 0x42,
0x10, 0x7d, 0x05, 0x05, 0x2f, 0x76, 0x21, 0xf5, 0x09, 0xb2, 0xf6, 0x90, 0x0d, 0x6c, 0x33, 0x93,
0x53, 0xc1, 0x4b, 0xf1, 0xc5, 0x25, 0x5f, 0xe8, 0x2e, 0x7f, 0xff, 0xf6, 0x7c, 0xfd, 0x02, 0xcb,
0x16, 0xf7, 0x83, 0x96, 0x27, 0x6b, 0xc8, 0x88, 0x35, 0xac, 0x5e, 0x50, 0xbd, 0xd3, 0xa1, 0xc6,
0x8f, 0x01, 0x1d, 0x89, 0x2d, 0x54, 0x39, 0x70, 0x27, 0xd3, 0x3b, 0x64, 0xd7, 0x30, 0x73, 0xa4,
0x68, 0x70, 0xbc, 0xb8, 0x29, 0xb6, 0x8b, 0x3a, 0x91, 0xa8, 0xe0, 0xf2, 0x8d, 0x14, 0xb9, 0x5c,
0xf9, 0x53, 0xc0, 0x2a, 0x05, 0xa9, 0x92, 0xc3, 0x85, 0x23, 0x65, 0x09, 0xdb, 0x50, 0x3a, 0xad,
0x33, 0xfa, 0x9e, 0xc3, 0x89, 0x8e, 0x1d, 0xf2, 0x71, 0xf8, 0x90, 0xc8, 0xe7, 0x1d, 0x76, 0xc6,
0x7e, 0xf1, 0x49, 0xcc, 0x23, 0xf9, 0x4e, 0x74, 0xb0, 0xa8, 0x5a, 0xc7, 0xa7, 0xb1, 0x53, 0x42,
0x56, 0xc1, 0x58, 0x37, 0xbc, 0x0c, 0xe1, 0x58, 0x37, 0xe2, 0x15, 0x60, 0x67, 0x74, 0xda, 0x89,
0x5d, 0x41, 0xd9, 0x98, 0xa1, 0xa7, 0x34, 0x3f, 0x82, 0x4f, 0xdd, 0xb1, 0x6f, 0xf2, 0xf0, 0x08,
0xf1, 0x4e, 0x8b, 0xaa, 0x0b, 0xb3, 0xe7, 0x75, 0x22, 0x21, 0x60, 0xbe, 0x33, 0xfa, 0xf9, 0x13,
0x7b, 0xf2, 0xff, 0x58, 0x6c, 0x8c, 0x6d, 0xb3, 0x8b, 0x48, 0x0f, 0xdf, 0x05, 0x94, 0x4f, 0x5e,
0x2b, 0xbb, 0x83, 0x59, 0xf4, 0xc7, 0x2a, 0x79, 0x66, 0x76, 0xb3, 0x96, 0xe7, 0x62, 0xc5, 0x88,
0x6d, 0xa1, 0x0c, 0xc6, 0xd8, 0x4a, 0xfe, 0x57, 0xb9, 0xa9, 0xe4, 0x99, 0x48, 0x31, 0x62, 0xb7,
0x30, 0xd9, 0x19, 0xcd, 0x96, 0xf2, 0xef, 0xb8, 0xcd, 0x42, 0xe6, 0xbd, 0xc4, 0xe8, 0xbe, 0xd8,
0xcf, 0xc2, 0x8b, 0x3e, 0xfe, 0x06, 0x00, 0x00, 0xff, 0xff, 0x70, 0x27, 0xbe, 0x8c, 0xe0, 0x01,
0x00, 0x00,
}

View File

@ -1,5 +1,5 @@
// Code generated by protoc-gen-micro. DO NOT EDIT.
// source: github.com/micro/go-micro/debug/proto/debug.proto
// source: debug.proto
package debug
@ -36,6 +36,7 @@ var _ server.Option
type DebugService interface {
Health(ctx context.Context, in *HealthRequest, opts ...client.CallOption) (*HealthResponse, error)
Stats(ctx context.Context, in *StatsRequest, opts ...client.CallOption) (*StatsResponse, error)
Log(ctx context.Context, in *LogRequest, opts ...client.CallOption) (Debug_LogService, error)
}
type debugService struct {
@ -76,17 +77,63 @@ func (c *debugService) Stats(ctx context.Context, in *StatsRequest, opts ...clie
return out, nil
}
func (c *debugService) Log(ctx context.Context, in *LogRequest, opts ...client.CallOption) (Debug_LogService, error) {
req := c.c.NewRequest(c.name, "Debug.Log", &LogRequest{})
stream, err := c.c.Stream(ctx, req, opts...)
if err != nil {
return nil, err
}
if err := stream.Send(in); err != nil {
return nil, err
}
return &debugServiceLog{stream}, nil
}
type Debug_LogService interface {
SendMsg(interface{}) error
RecvMsg(interface{}) error
Close() error
Recv() (*LogEvent, error)
}
type debugServiceLog struct {
stream client.Stream
}
func (x *debugServiceLog) Close() error {
return x.stream.Close()
}
func (x *debugServiceLog) SendMsg(m interface{}) error {
return x.stream.Send(m)
}
func (x *debugServiceLog) RecvMsg(m interface{}) error {
return x.stream.Recv(m)
}
func (x *debugServiceLog) Recv() (*LogEvent, error) {
m := new(LogEvent)
err := x.stream.Recv(m)
if err != nil {
return nil, err
}
return m, nil
}
// Server API for Debug service
type DebugHandler interface {
Health(context.Context, *HealthRequest, *HealthResponse) error
Stats(context.Context, *StatsRequest, *StatsResponse) error
Log(context.Context, *LogRequest, Debug_LogStream) error
}
func RegisterDebugHandler(s server.Server, hdlr DebugHandler, opts ...server.HandlerOption) error {
type debug interface {
Health(ctx context.Context, in *HealthRequest, out *HealthResponse) error
Stats(ctx context.Context, in *StatsRequest, out *StatsResponse) error
Log(ctx context.Context, stream server.Stream) error
}
type Debug struct {
debug
@ -106,3 +153,38 @@ func (h *debugHandler) Health(ctx context.Context, in *HealthRequest, out *Healt
func (h *debugHandler) Stats(ctx context.Context, in *StatsRequest, out *StatsResponse) error {
return h.DebugHandler.Stats(ctx, in, out)
}
func (h *debugHandler) Log(ctx context.Context, stream server.Stream) error {
m := new(LogRequest)
if err := stream.Recv(m); err != nil {
return err
}
return h.DebugHandler.Log(ctx, m, &debugLogStream{stream})
}
type Debug_LogStream interface {
SendMsg(interface{}) error
RecvMsg(interface{}) error
Close() error
Send(*LogEvent) error
}
type debugLogStream struct {
stream server.Stream
}
func (x *debugLogStream) Close() error {
return x.stream.Close()
}
func (x *debugLogStream) SendMsg(m interface{}) error {
return x.stream.Send(m)
}
func (x *debugLogStream) RecvMsg(m interface{}) error {
return x.stream.Recv(m)
}
func (x *debugLogStream) Send(m *LogEvent) error {
return x.stream.Send(m)
}

View File

@ -1,20 +1,19 @@
syntax = "proto3";
service Debug {
rpc Health(HealthRequest) returns (HealthResponse) {}
rpc Stats(StatsRequest) returns (StatsResponse) {}
rpc Health(HealthRequest) returns (HealthResponse) {};
rpc Stats(StatsRequest) returns (StatsResponse) {};
rpc Log(LogRequest) returns (stream LogEvent) {};
}
message HealthRequest {
}
message HealthRequest {}
message HealthResponse {
// default: ok
string status = 1;
}
message StatsRequest {
}
message StatsRequest {}
message StatsResponse {
// unix timestamp
@ -28,3 +27,22 @@ message StatsResponse {
// total gc in nanoseconds
uint64 gc = 5;
}
// LogRequest queries service for logs
message LogRequest {
// count is the count of events
uint64 count = 1;
// relative time in seconds
// before the current time
// from which to show logs
uint64 since = 2;
// stream logs continuously
bool stream = 3;
}
// LogEvent is service log event
message LogEvent {
// event log record
// TODO: change this
string record = 1;
}