mirror of
https://github.com/go-micro/go-micro.git
synced 2025-08-04 21:42:57 +02:00
Move debug handler to service dir
This commit is contained in:
@ -1,389 +0,0 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// source: github.com/micro/go-micro/debug/proto/debug.proto
|
||||
|
||||
package debug
|
||||
|
||||
import (
|
||||
fmt "fmt"
|
||||
proto "github.com/golang/protobuf/proto"
|
||||
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 HealthRequest struct {
|
||||
// optional service name
|
||||
Service string `protobuf:"bytes,1,opt,name=service,proto3" json:"service,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
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}
|
||||
}
|
||||
|
||||
func (m *HealthRequest) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_HealthRequest.Unmarshal(m, b)
|
||||
}
|
||||
func (m *HealthRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_HealthRequest.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (m *HealthRequest) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_HealthRequest.Merge(m, src)
|
||||
}
|
||||
func (m *HealthRequest) XXX_Size() int {
|
||||
return xxx_messageInfo_HealthRequest.Size(m)
|
||||
}
|
||||
func (m *HealthRequest) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_HealthRequest.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_HealthRequest proto.InternalMessageInfo
|
||||
|
||||
func (m *HealthRequest) GetService() string {
|
||||
if m != nil {
|
||||
return m.Service
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type HealthResponse struct {
|
||||
// default: ok
|
||||
Status string `protobuf:"bytes,1,opt,name=status,proto3" json:"status,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
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}
|
||||
}
|
||||
|
||||
func (m *HealthResponse) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_HealthResponse.Unmarshal(m, b)
|
||||
}
|
||||
func (m *HealthResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_HealthResponse.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (m *HealthResponse) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_HealthResponse.Merge(m, src)
|
||||
}
|
||||
func (m *HealthResponse) XXX_Size() int {
|
||||
return xxx_messageInfo_HealthResponse.Size(m)
|
||||
}
|
||||
func (m *HealthResponse) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_HealthResponse.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_HealthResponse proto.InternalMessageInfo
|
||||
|
||||
func (m *HealthResponse) GetStatus() string {
|
||||
if m != nil {
|
||||
return m.Status
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type StatsRequest struct {
|
||||
// optional service name
|
||||
Service string `protobuf:"bytes,1,opt,name=service,proto3" json:"service,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
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}
|
||||
}
|
||||
|
||||
func (m *StatsRequest) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_StatsRequest.Unmarshal(m, b)
|
||||
}
|
||||
func (m *StatsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_StatsRequest.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (m *StatsRequest) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_StatsRequest.Merge(m, src)
|
||||
}
|
||||
func (m *StatsRequest) XXX_Size() int {
|
||||
return xxx_messageInfo_StatsRequest.Size(m)
|
||||
}
|
||||
func (m *StatsRequest) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_StatsRequest.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_StatsRequest proto.InternalMessageInfo
|
||||
|
||||
func (m *StatsRequest) GetService() string {
|
||||
if m != nil {
|
||||
return m.Service
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type StatsResponse struct {
|
||||
// unix timestamp
|
||||
Started uint64 `protobuf:"varint,1,opt,name=started,proto3" json:"started,omitempty"`
|
||||
// in seconds
|
||||
Uptime uint64 `protobuf:"varint,2,opt,name=uptime,proto3" json:"uptime,omitempty"`
|
||||
// in bytes
|
||||
Memory uint64 `protobuf:"varint,3,opt,name=memory,proto3" json:"memory,omitempty"`
|
||||
// num threads
|
||||
Threads uint64 `protobuf:"varint,4,opt,name=threads,proto3" json:"threads,omitempty"`
|
||||
// total gc in nanoseconds
|
||||
Gc uint64 `protobuf:"varint,5,opt,name=gc,proto3" json:"gc,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
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}
|
||||
}
|
||||
|
||||
func (m *StatsResponse) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_StatsResponse.Unmarshal(m, b)
|
||||
}
|
||||
func (m *StatsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_StatsResponse.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (m *StatsResponse) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_StatsResponse.Merge(m, src)
|
||||
}
|
||||
func (m *StatsResponse) XXX_Size() int {
|
||||
return xxx_messageInfo_StatsResponse.Size(m)
|
||||
}
|
||||
func (m *StatsResponse) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_StatsResponse.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_StatsResponse proto.InternalMessageInfo
|
||||
|
||||
func (m *StatsResponse) GetStarted() uint64 {
|
||||
if m != nil {
|
||||
return m.Started
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *StatsResponse) GetUptime() uint64 {
|
||||
if m != nil {
|
||||
return m.Uptime
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *StatsResponse) GetMemory() uint64 {
|
||||
if m != nil {
|
||||
return m.Memory
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *StatsResponse) GetThreads() uint64 {
|
||||
if m != nil {
|
||||
return m.Threads
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *StatsResponse) GetGc() uint64 {
|
||||
if m != nil {
|
||||
return m.Gc
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
// LogRequest requests service logs
|
||||
type LogRequest struct {
|
||||
// service to request logs for
|
||||
Service string `protobuf:"bytes,1,opt,name=service,proto3" json:"service,omitempty"`
|
||||
// stream records continuously
|
||||
Stream bool `protobuf:"varint,2,opt,name=stream,proto3" json:"stream,omitempty"`
|
||||
// count of records to request
|
||||
Count int64 `protobuf:"varint,3,opt,name=count,proto3" json:"count,omitempty"`
|
||||
// relative time in seconds
|
||||
// before the current time
|
||||
// from which to show logs
|
||||
Since int64 `protobuf:"varint,4,opt,name=since,proto3" json:"since,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_7cb19b1a05a6e0a9, []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) GetService() string {
|
||||
if m != nil {
|
||||
return m.Service
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *LogRequest) GetStream() bool {
|
||||
if m != nil {
|
||||
return m.Stream
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (m *LogRequest) GetCount() int64 {
|
||||
if m != nil {
|
||||
return m.Count
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *LogRequest) GetSince() int64 {
|
||||
if m != nil {
|
||||
return m.Since
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
// Record is service log record
|
||||
type Record struct {
|
||||
// timestamp of log record
|
||||
Timestamp int64 `protobuf:"varint,1,opt,name=timestamp,proto3" json:"timestamp,omitempty"`
|
||||
// record value
|
||||
Value string `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"`
|
||||
// record metadata
|
||||
Metadata map[string]string `protobuf:"bytes,3,rep,name=metadata,proto3" json:"metadata,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *Record) Reset() { *m = Record{} }
|
||||
func (m *Record) String() string { return proto.CompactTextString(m) }
|
||||
func (*Record) ProtoMessage() {}
|
||||
func (*Record) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_7cb19b1a05a6e0a9, []int{5}
|
||||
}
|
||||
|
||||
func (m *Record) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_Record.Unmarshal(m, b)
|
||||
}
|
||||
func (m *Record) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_Record.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (m *Record) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_Record.Merge(m, src)
|
||||
}
|
||||
func (m *Record) XXX_Size() int {
|
||||
return xxx_messageInfo_Record.Size(m)
|
||||
}
|
||||
func (m *Record) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_Record.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_Record proto.InternalMessageInfo
|
||||
|
||||
func (m *Record) GetTimestamp() int64 {
|
||||
if m != nil {
|
||||
return m.Timestamp
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *Record) GetValue() string {
|
||||
if m != nil {
|
||||
return m.Value
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *Record) GetMetadata() map[string]string {
|
||||
if m != nil {
|
||||
return m.Metadata
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
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((*Record)(nil), "Record")
|
||||
proto.RegisterMapType((map[string]string)(nil), "Record.MetadataEntry")
|
||||
}
|
||||
|
||||
func init() {
|
||||
proto.RegisterFile("github.com/micro/go-micro/debug/proto/debug.proto", fileDescriptor_7cb19b1a05a6e0a9)
|
||||
}
|
||||
|
||||
var fileDescriptor_7cb19b1a05a6e0a9 = []byte{
|
||||
// 400 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x92, 0xcd, 0x8a, 0x13, 0x41,
|
||||
0x10, 0xc7, 0x33, 0x99, 0x24, 0xbb, 0xa9, 0x35, 0x51, 0x1a, 0x95, 0x21, 0x78, 0x08, 0x7d, 0x1a,
|
||||
0x11, 0x3b, 0xee, 0x7a, 0x11, 0xbd, 0x2a, 0x78, 0x58, 0x2f, 0xed, 0x13, 0x74, 0x7a, 0x8a, 0xc9,
|
||||
0xe8, 0x76, 0x3a, 0x76, 0xd7, 0x2c, 0xe4, 0x26, 0xf8, 0x3a, 0x3e, 0xa4, 0xf4, 0x47, 0x5c, 0x07,
|
||||
0x84, 0xdc, 0xea, 0xf7, 0xef, 0x7f, 0xd7, 0x07, 0x55, 0x70, 0xdd, 0x76, 0xb4, 0xeb, 0xb7, 0x42,
|
||||
0x5b, 0xb3, 0x31, 0x9d, 0x76, 0x76, 0xd3, 0xda, 0xd7, 0x29, 0x68, 0x70, 0xdb, 0xb7, 0x9b, 0x83,
|
||||
0xb3, 0x94, 0x63, 0x11, 0x63, 0xfe, 0x12, 0x16, 0x9f, 0x51, 0xdd, 0xd1, 0x4e, 0xe2, 0x8f, 0x1e,
|
||||
0x3d, 0xb1, 0x0a, 0x2e, 0x3c, 0xba, 0xfb, 0x4e, 0x63, 0x55, 0xac, 0x8b, 0x7a, 0x2e, 0x4f, 0xc8,
|
||||
0x6b, 0x58, 0x9e, 0xac, 0xfe, 0x60, 0xf7, 0x1e, 0xd9, 0x73, 0x98, 0x79, 0x52, 0xd4, 0xfb, 0x6c,
|
||||
0xcd, 0xc4, 0x6b, 0x78, 0xf4, 0x95, 0x14, 0xf9, 0xf3, 0x39, 0x7f, 0x15, 0xb0, 0xc8, 0xd6, 0x9c,
|
||||
0x33, 0x78, 0x49, 0x39, 0xc2, 0x26, 0x7a, 0x27, 0xf2, 0x84, 0xa1, 0x5a, 0x7f, 0xa0, 0xce, 0x60,
|
||||
0x35, 0x8e, 0x0f, 0x99, 0x82, 0x6e, 0xd0, 0x58, 0x77, 0xac, 0xca, 0xa4, 0x27, 0x0a, 0x99, 0x68,
|
||||
0xe7, 0x50, 0x35, 0xbe, 0x9a, 0xa4, 0x4c, 0x19, 0xd9, 0x12, 0xc6, 0xad, 0xae, 0xa6, 0x51, 0x1c,
|
||||
0xb7, 0x9a, 0x7f, 0x03, 0xb8, 0xb5, 0xed, 0xd9, 0x6e, 0xd3, 0xbc, 0x0e, 0x95, 0x89, 0x1d, 0x5c,
|
||||
0xca, 0x4c, 0xec, 0x29, 0x4c, 0xb5, 0xed, 0xf7, 0x14, 0x1b, 0x28, 0x65, 0x82, 0xa0, 0xfa, 0x6e,
|
||||
0xaf, 0x31, 0x56, 0x2f, 0x65, 0x02, 0xfe, 0xbb, 0x80, 0x99, 0x44, 0x6d, 0x5d, 0xc3, 0x5e, 0xc0,
|
||||
0x3c, 0x0c, 0xe0, 0x49, 0x99, 0x43, 0x2c, 0x55, 0xca, 0x07, 0x21, 0x7c, 0xbf, 0x57, 0x77, 0x7d,
|
||||
0x9a, 0x76, 0x2e, 0x13, 0xb0, 0x6b, 0xb8, 0x34, 0x48, 0xaa, 0x51, 0xa4, 0xaa, 0x72, 0x5d, 0xd6,
|
||||
0x57, 0x37, 0xcf, 0x44, 0x4a, 0x27, 0xbe, 0x64, 0xfd, 0xd3, 0x9e, 0xdc, 0x51, 0xfe, 0xb5, 0xad,
|
||||
0x3e, 0xc0, 0x62, 0xf0, 0xc4, 0x9e, 0x40, 0xf9, 0x1d, 0x8f, 0x79, 0xb8, 0x10, 0xfe, 0xbf, 0xd6,
|
||||
0xfb, 0xf1, 0xbb, 0xe2, 0xe6, 0x67, 0x01, 0xd3, 0x8f, 0xe1, 0x5e, 0xd8, 0x2b, 0x98, 0xa5, 0xf5,
|
||||
0xb3, 0xa5, 0x18, 0x9c, 0xcc, 0xea, 0xb1, 0x18, 0xde, 0x05, 0x1f, 0xb1, 0x1a, 0xa6, 0x71, 0xad,
|
||||
0x6c, 0x21, 0xfe, 0xbd, 0x84, 0xd5, 0x52, 0x0c, 0xb6, 0xcd, 0x47, 0x6c, 0x0d, 0x93, 0x5b, 0xdb,
|
||||
0x7a, 0x76, 0x25, 0x1e, 0x56, 0xb0, 0xba, 0xc8, 0x33, 0xf1, 0xd1, 0x9b, 0x62, 0x3b, 0x8b, 0x97,
|
||||
0xfa, 0xf6, 0x4f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x35, 0x1e, 0x9c, 0xa7, 0xde, 0x02, 0x00, 0x00,
|
||||
}
|
@ -1,190 +0,0 @@
|
||||
// Code generated by protoc-gen-micro. DO NOT EDIT.
|
||||
// source: github.com/micro/go-micro/debug/proto/debug.proto
|
||||
|
||||
package debug
|
||||
|
||||
import (
|
||||
fmt "fmt"
|
||||
proto "github.com/golang/protobuf/proto"
|
||||
math "math"
|
||||
)
|
||||
|
||||
import (
|
||||
context "context"
|
||||
client "github.com/micro/go-micro/client"
|
||||
server "github.com/micro/go-micro/server"
|
||||
)
|
||||
|
||||
// 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
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
var _ context.Context
|
||||
var _ client.Option
|
||||
var _ server.Option
|
||||
|
||||
// Client API for Debug service
|
||||
|
||||
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)
|
||||
Logs(ctx context.Context, in *LogRequest, opts ...client.CallOption) (Debug_LogsService, error)
|
||||
}
|
||||
|
||||
type debugService struct {
|
||||
c client.Client
|
||||
name string
|
||||
}
|
||||
|
||||
func NewDebugService(name string, c client.Client) DebugService {
|
||||
if c == nil {
|
||||
c = client.NewClient()
|
||||
}
|
||||
if len(name) == 0 {
|
||||
name = "debug"
|
||||
}
|
||||
return &debugService{
|
||||
c: c,
|
||||
name: name,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *debugService) Health(ctx context.Context, in *HealthRequest, opts ...client.CallOption) (*HealthResponse, error) {
|
||||
req := c.c.NewRequest(c.name, "Debug.Health", in)
|
||||
out := new(HealthResponse)
|
||||
err := c.c.Call(ctx, req, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *debugService) Stats(ctx context.Context, in *StatsRequest, opts ...client.CallOption) (*StatsResponse, error) {
|
||||
req := c.c.NewRequest(c.name, "Debug.Stats", in)
|
||||
out := new(StatsResponse)
|
||||
err := c.c.Call(ctx, req, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *debugService) Logs(ctx context.Context, in *LogRequest, opts ...client.CallOption) (Debug_LogsService, error) {
|
||||
req := c.c.NewRequest(c.name, "Debug.Logs", &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 &debugServiceLogs{stream}, nil
|
||||
}
|
||||
|
||||
type Debug_LogsService interface {
|
||||
SendMsg(interface{}) error
|
||||
RecvMsg(interface{}) error
|
||||
Close() error
|
||||
Recv() (*Record, error)
|
||||
}
|
||||
|
||||
type debugServiceLogs struct {
|
||||
stream client.Stream
|
||||
}
|
||||
|
||||
func (x *debugServiceLogs) Close() error {
|
||||
return x.stream.Close()
|
||||
}
|
||||
|
||||
func (x *debugServiceLogs) SendMsg(m interface{}) error {
|
||||
return x.stream.Send(m)
|
||||
}
|
||||
|
||||
func (x *debugServiceLogs) RecvMsg(m interface{}) error {
|
||||
return x.stream.Recv(m)
|
||||
}
|
||||
|
||||
func (x *debugServiceLogs) Recv() (*Record, error) {
|
||||
m := new(Record)
|
||||
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
|
||||
Logs(context.Context, *LogRequest, Debug_LogsStream) 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
|
||||
Logs(ctx context.Context, stream server.Stream) error
|
||||
}
|
||||
type Debug struct {
|
||||
debug
|
||||
}
|
||||
h := &debugHandler{hdlr}
|
||||
return s.Handle(s.NewHandler(&Debug{h}, opts...))
|
||||
}
|
||||
|
||||
type debugHandler struct {
|
||||
DebugHandler
|
||||
}
|
||||
|
||||
func (h *debugHandler) Health(ctx context.Context, in *HealthRequest, out *HealthResponse) error {
|
||||
return h.DebugHandler.Health(ctx, in, out)
|
||||
}
|
||||
|
||||
func (h *debugHandler) Stats(ctx context.Context, in *StatsRequest, out *StatsResponse) error {
|
||||
return h.DebugHandler.Stats(ctx, in, out)
|
||||
}
|
||||
|
||||
func (h *debugHandler) Logs(ctx context.Context, stream server.Stream) error {
|
||||
m := new(LogRequest)
|
||||
if err := stream.Recv(m); err != nil {
|
||||
return err
|
||||
}
|
||||
return h.DebugHandler.Logs(ctx, m, &debugLogsStream{stream})
|
||||
}
|
||||
|
||||
type Debug_LogsStream interface {
|
||||
SendMsg(interface{}) error
|
||||
RecvMsg(interface{}) error
|
||||
Close() error
|
||||
Send(*Record) error
|
||||
}
|
||||
|
||||
type debugLogsStream struct {
|
||||
stream server.Stream
|
||||
}
|
||||
|
||||
func (x *debugLogsStream) Close() error {
|
||||
return x.stream.Close()
|
||||
}
|
||||
|
||||
func (x *debugLogsStream) SendMsg(m interface{}) error {
|
||||
return x.stream.Send(m)
|
||||
}
|
||||
|
||||
func (x *debugLogsStream) RecvMsg(m interface{}) error {
|
||||
return x.stream.Recv(m)
|
||||
}
|
||||
|
||||
func (x *debugLogsStream) Send(m *Record) error {
|
||||
return x.stream.Send(m)
|
||||
}
|
@ -1,59 +0,0 @@
|
||||
syntax = "proto3";
|
||||
|
||||
service Debug {
|
||||
rpc Health(HealthRequest) returns (HealthResponse) {};
|
||||
rpc Stats(StatsRequest) returns (StatsResponse) {};
|
||||
rpc Logs(LogRequest) returns (stream Record) {};
|
||||
}
|
||||
|
||||
message HealthRequest {
|
||||
// optional service name
|
||||
string service = 1;
|
||||
}
|
||||
|
||||
message HealthResponse {
|
||||
// default: ok
|
||||
string status = 1;
|
||||
}
|
||||
|
||||
message StatsRequest {
|
||||
// optional service name
|
||||
string service = 1;
|
||||
}
|
||||
|
||||
message StatsResponse {
|
||||
// unix timestamp
|
||||
uint64 started = 1;
|
||||
// in seconds
|
||||
uint64 uptime = 2;
|
||||
// in bytes
|
||||
uint64 memory = 3;
|
||||
// num threads
|
||||
uint64 threads = 4;
|
||||
// total gc in nanoseconds
|
||||
uint64 gc = 5;
|
||||
}
|
||||
|
||||
// LogRequest requests service logs
|
||||
message LogRequest {
|
||||
// service to request logs for
|
||||
string service = 1;
|
||||
// stream records continuously
|
||||
bool stream = 2;
|
||||
// count of records to request
|
||||
int64 count = 3;
|
||||
// relative time in seconds
|
||||
// before the current time
|
||||
// from which to show logs
|
||||
int64 since = 4;
|
||||
}
|
||||
|
||||
// Record is service log record
|
||||
message Record {
|
||||
// timestamp of log record
|
||||
int64 timestamp = 1;
|
||||
// record value
|
||||
string value = 2;
|
||||
// record metadata
|
||||
map<string,string> metadata = 3;
|
||||
}
|
Reference in New Issue
Block a user