mirror of
https://github.com/lightninglabs/lightning-terminal.git
synced 2026-08-13 12:33:36 +02:00
litrpc: add Status server protos
Add the protos for a new Status server that can be used to query the status of a number of LiT's subservers.
This commit is contained in:
parent
5f481baecb
commit
4006622df6
7 changed files with 748 additions and 0 deletions
305
litrpc/lit-status.pb.go
Normal file
305
litrpc/lit-status.pb.go
Normal file
|
|
@ -0,0 +1,305 @@
|
|||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.30.0
|
||||
// protoc v3.6.1
|
||||
// source: lit-status.proto
|
||||
|
||||
package litrpc
|
||||
|
||||
import (
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||
reflect "reflect"
|
||||
sync "sync"
|
||||
)
|
||||
|
||||
const (
|
||||
// Verify that this generated code is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
|
||||
// Verify that runtime/protoimpl is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
||||
)
|
||||
|
||||
type SubServerStatusReq struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
}
|
||||
|
||||
func (x *SubServerStatusReq) Reset() {
|
||||
*x = SubServerStatusReq{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_lit_status_proto_msgTypes[0]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *SubServerStatusReq) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*SubServerStatusReq) ProtoMessage() {}
|
||||
|
||||
func (x *SubServerStatusReq) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_lit_status_proto_msgTypes[0]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use SubServerStatusReq.ProtoReflect.Descriptor instead.
|
||||
func (*SubServerStatusReq) Descriptor() ([]byte, []int) {
|
||||
return file_lit_status_proto_rawDescGZIP(), []int{0}
|
||||
}
|
||||
|
||||
type SubServerStatusResp struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
// A map of sub-server names to their status.
|
||||
SubServers map[string]*SubServerStatus `protobuf:"bytes,1,rep,name=sub_servers,json=subServers,proto3" json:"sub_servers,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
|
||||
}
|
||||
|
||||
func (x *SubServerStatusResp) Reset() {
|
||||
*x = SubServerStatusResp{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_lit_status_proto_msgTypes[1]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *SubServerStatusResp) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*SubServerStatusResp) ProtoMessage() {}
|
||||
|
||||
func (x *SubServerStatusResp) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_lit_status_proto_msgTypes[1]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use SubServerStatusResp.ProtoReflect.Descriptor instead.
|
||||
func (*SubServerStatusResp) Descriptor() ([]byte, []int) {
|
||||
return file_lit_status_proto_rawDescGZIP(), []int{1}
|
||||
}
|
||||
|
||||
func (x *SubServerStatusResp) GetSubServers() map[string]*SubServerStatus {
|
||||
if x != nil {
|
||||
return x.SubServers
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type SubServerStatus struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
// disabled is true if the sub-server is available in the LiT package but
|
||||
// has explicitly been disabled.
|
||||
Disabled bool `protobuf:"varint,1,opt,name=disabled,proto3" json:"disabled,omitempty"`
|
||||
// running is true if the sub-server is currently running.
|
||||
Running bool `protobuf:"varint,2,opt,name=running,proto3" json:"running,omitempty"`
|
||||
// error describes an error that might have resulted in the sub-server not
|
||||
// starting up properly.
|
||||
Error string `protobuf:"bytes,3,opt,name=error,proto3" json:"error,omitempty"`
|
||||
}
|
||||
|
||||
func (x *SubServerStatus) Reset() {
|
||||
*x = SubServerStatus{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_lit_status_proto_msgTypes[2]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *SubServerStatus) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*SubServerStatus) ProtoMessage() {}
|
||||
|
||||
func (x *SubServerStatus) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_lit_status_proto_msgTypes[2]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use SubServerStatus.ProtoReflect.Descriptor instead.
|
||||
func (*SubServerStatus) Descriptor() ([]byte, []int) {
|
||||
return file_lit_status_proto_rawDescGZIP(), []int{2}
|
||||
}
|
||||
|
||||
func (x *SubServerStatus) GetDisabled() bool {
|
||||
if x != nil {
|
||||
return x.Disabled
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (x *SubServerStatus) GetRunning() bool {
|
||||
if x != nil {
|
||||
return x.Running
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (x *SubServerStatus) GetError() string {
|
||||
if x != nil {
|
||||
return x.Error
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
var File_lit_status_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_lit_status_proto_rawDesc = []byte{
|
||||
0x0a, 0x10, 0x6c, 0x69, 0x74, 0x2d, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x2e, 0x70, 0x72, 0x6f,
|
||||
0x74, 0x6f, 0x12, 0x06, 0x6c, 0x69, 0x74, 0x72, 0x70, 0x63, 0x22, 0x14, 0x0a, 0x12, 0x53, 0x75,
|
||||
0x62, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71,
|
||||
0x22, 0xbb, 0x01, 0x0a, 0x13, 0x53, 0x75, 0x62, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74,
|
||||
0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x12, 0x4c, 0x0a, 0x0b, 0x73, 0x75, 0x62, 0x5f,
|
||||
0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2b, 0x2e,
|
||||
0x6c, 0x69, 0x74, 0x72, 0x70, 0x63, 0x2e, 0x53, 0x75, 0x62, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72,
|
||||
0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x2e, 0x53, 0x75, 0x62, 0x53, 0x65,
|
||||
0x72, 0x76, 0x65, 0x72, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x0a, 0x73, 0x75, 0x62, 0x53,
|
||||
0x65, 0x72, 0x76, 0x65, 0x72, 0x73, 0x1a, 0x56, 0x0a, 0x0f, 0x53, 0x75, 0x62, 0x53, 0x65, 0x72,
|
||||
0x76, 0x65, 0x72, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79,
|
||||
0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x2d, 0x0a, 0x05, 0x76,
|
||||
0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x6c, 0x69, 0x74,
|
||||
0x72, 0x70, 0x63, 0x2e, 0x53, 0x75, 0x62, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61,
|
||||
0x74, 0x75, 0x73, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x5d,
|
||||
0x0a, 0x0f, 0x53, 0x75, 0x62, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75,
|
||||
0x73, 0x12, 0x1a, 0x0a, 0x08, 0x64, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x18, 0x01, 0x20,
|
||||
0x01, 0x28, 0x08, 0x52, 0x08, 0x64, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x12, 0x18, 0x0a,
|
||||
0x07, 0x72, 0x75, 0x6e, 0x6e, 0x69, 0x6e, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07,
|
||||
0x72, 0x75, 0x6e, 0x6e, 0x69, 0x6e, 0x67, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72,
|
||||
0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x32, 0x54, 0x0a,
|
||||
0x06, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x4a, 0x0a, 0x0f, 0x53, 0x75, 0x62, 0x53, 0x65,
|
||||
0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x1a, 0x2e, 0x6c, 0x69, 0x74,
|
||||
0x72, 0x70, 0x63, 0x2e, 0x53, 0x75, 0x62, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61,
|
||||
0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x1a, 0x1b, 0x2e, 0x6c, 0x69, 0x74, 0x72, 0x70, 0x63, 0x2e,
|
||||
0x53, 0x75, 0x62, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52,
|
||||
0x65, 0x73, 0x70, 0x42, 0x34, 0x5a, 0x32, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f,
|
||||
0x6d, 0x2f, 0x6c, 0x69, 0x67, 0x68, 0x74, 0x6e, 0x69, 0x6e, 0x67, 0x6c, 0x61, 0x62, 0x73, 0x2f,
|
||||
0x6c, 0x69, 0x67, 0x68, 0x74, 0x6e, 0x69, 0x6e, 0x67, 0x2d, 0x74, 0x65, 0x72, 0x6d, 0x69, 0x6e,
|
||||
0x61, 0x6c, 0x2f, 0x6c, 0x69, 0x74, 0x72, 0x70, 0x63, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f,
|
||||
0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
file_lit_status_proto_rawDescOnce sync.Once
|
||||
file_lit_status_proto_rawDescData = file_lit_status_proto_rawDesc
|
||||
)
|
||||
|
||||
func file_lit_status_proto_rawDescGZIP() []byte {
|
||||
file_lit_status_proto_rawDescOnce.Do(func() {
|
||||
file_lit_status_proto_rawDescData = protoimpl.X.CompressGZIP(file_lit_status_proto_rawDescData)
|
||||
})
|
||||
return file_lit_status_proto_rawDescData
|
||||
}
|
||||
|
||||
var file_lit_status_proto_msgTypes = make([]protoimpl.MessageInfo, 4)
|
||||
var file_lit_status_proto_goTypes = []interface{}{
|
||||
(*SubServerStatusReq)(nil), // 0: litrpc.SubServerStatusReq
|
||||
(*SubServerStatusResp)(nil), // 1: litrpc.SubServerStatusResp
|
||||
(*SubServerStatus)(nil), // 2: litrpc.SubServerStatus
|
||||
nil, // 3: litrpc.SubServerStatusResp.SubServersEntry
|
||||
}
|
||||
var file_lit_status_proto_depIdxs = []int32{
|
||||
3, // 0: litrpc.SubServerStatusResp.sub_servers:type_name -> litrpc.SubServerStatusResp.SubServersEntry
|
||||
2, // 1: litrpc.SubServerStatusResp.SubServersEntry.value:type_name -> litrpc.SubServerStatus
|
||||
0, // 2: litrpc.Status.SubServerStatus:input_type -> litrpc.SubServerStatusReq
|
||||
1, // 3: litrpc.Status.SubServerStatus:output_type -> litrpc.SubServerStatusResp
|
||||
3, // [3:4] is the sub-list for method output_type
|
||||
2, // [2:3] is the sub-list for method input_type
|
||||
2, // [2:2] is the sub-list for extension type_name
|
||||
2, // [2:2] is the sub-list for extension extendee
|
||||
0, // [0:2] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_lit_status_proto_init() }
|
||||
func file_lit_status_proto_init() {
|
||||
if File_lit_status_proto != nil {
|
||||
return
|
||||
}
|
||||
if !protoimpl.UnsafeEnabled {
|
||||
file_lit_status_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*SubServerStatusReq); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_lit_status_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*SubServerStatusResp); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_lit_status_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*SubServerStatus); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
type x struct{}
|
||||
out := protoimpl.TypeBuilder{
|
||||
File: protoimpl.DescBuilder{
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: file_lit_status_proto_rawDesc,
|
||||
NumEnums: 0,
|
||||
NumMessages: 4,
|
||||
NumExtensions: 0,
|
||||
NumServices: 1,
|
||||
},
|
||||
GoTypes: file_lit_status_proto_goTypes,
|
||||
DependencyIndexes: file_lit_status_proto_depIdxs,
|
||||
MessageInfos: file_lit_status_proto_msgTypes,
|
||||
}.Build()
|
||||
File_lit_status_proto = out.File
|
||||
file_lit_status_proto_rawDesc = nil
|
||||
file_lit_status_proto_goTypes = nil
|
||||
file_lit_status_proto_depIdxs = nil
|
||||
}
|
||||
151
litrpc/lit-status.pb.gw.go
Normal file
151
litrpc/lit-status.pb.gw.go
Normal file
|
|
@ -0,0 +1,151 @@
|
|||
// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT.
|
||||
// source: lit-status.proto
|
||||
|
||||
/*
|
||||
Package litrpc is a reverse proxy.
|
||||
|
||||
It translates gRPC into RESTful JSON APIs.
|
||||
*/
|
||||
package litrpc
|
||||
|
||||
import (
|
||||
"context"
|
||||
"io"
|
||||
"net/http"
|
||||
|
||||
"github.com/grpc-ecosystem/grpc-gateway/v2/runtime"
|
||||
"github.com/grpc-ecosystem/grpc-gateway/v2/utilities"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/grpclog"
|
||||
"google.golang.org/grpc/metadata"
|
||||
"google.golang.org/grpc/status"
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
// Suppress "imported and not used" errors
|
||||
var _ codes.Code
|
||||
var _ io.Reader
|
||||
var _ status.Status
|
||||
var _ = runtime.String
|
||||
var _ = utilities.NewDoubleArray
|
||||
var _ = metadata.Join
|
||||
|
||||
func request_Status_SubServerStatus_0(ctx context.Context, marshaler runtime.Marshaler, client StatusClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq SubServerStatusReq
|
||||
var metadata runtime.ServerMetadata
|
||||
|
||||
msg, err := client.SubServerStatus(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
||||
return msg, metadata, err
|
||||
|
||||
}
|
||||
|
||||
func local_request_Status_SubServerStatus_0(ctx context.Context, marshaler runtime.Marshaler, server StatusServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq SubServerStatusReq
|
||||
var metadata runtime.ServerMetadata
|
||||
|
||||
msg, err := server.SubServerStatus(ctx, &protoReq)
|
||||
return msg, metadata, err
|
||||
|
||||
}
|
||||
|
||||
// RegisterStatusHandlerServer registers the http handlers for service Status to "mux".
|
||||
// UnaryRPC :call StatusServer 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 RegisterStatusHandlerFromEndpoint instead.
|
||||
func RegisterStatusHandlerServer(ctx context.Context, mux *runtime.ServeMux, server StatusServer) error {
|
||||
|
||||
mux.Handle("GET", pattern_Status_SubServerStatus_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
var stream runtime.ServerTransportStream
|
||||
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/litrpc.Status/SubServerStatus", runtime.WithHTTPPathPattern("/v1/status"))
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := local_request_Status_SubServerStatus_0(rctx, inboundMarshaler, server, req, pathParams)
|
||||
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
|
||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
|
||||
forward_Status_SubServerStatus_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
|
||||
})
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// RegisterStatusHandlerFromEndpoint is same as RegisterStatusHandler but
|
||||
// automatically dials to "endpoint" and closes the connection when "ctx" gets done.
|
||||
func RegisterStatusHandlerFromEndpoint(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 RegisterStatusHandler(ctx, mux, conn)
|
||||
}
|
||||
|
||||
// RegisterStatusHandler registers the http handlers for service Status to "mux".
|
||||
// The handlers forward requests to the grpc endpoint over "conn".
|
||||
func RegisterStatusHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error {
|
||||
return RegisterStatusHandlerClient(ctx, mux, NewStatusClient(conn))
|
||||
}
|
||||
|
||||
// RegisterStatusHandlerClient registers the http handlers for service Status
|
||||
// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "StatusClient".
|
||||
// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "StatusClient"
|
||||
// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in
|
||||
// "StatusClient" to call the correct interceptors.
|
||||
func RegisterStatusHandlerClient(ctx context.Context, mux *runtime.ServeMux, client StatusClient) error {
|
||||
|
||||
mux.Handle("GET", pattern_Status_SubServerStatus_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, "/litrpc.Status/SubServerStatus", runtime.WithHTTPPathPattern("/v1/status"))
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := request_Status_SubServerStatus_0(rctx, inboundMarshaler, client, req, pathParams)
|
||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
|
||||
forward_Status_SubServerStatus_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
|
||||
})
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
var (
|
||||
pattern_Status_SubServerStatus_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "status"}, ""))
|
||||
)
|
||||
|
||||
var (
|
||||
forward_Status_SubServerStatus_0 = runtime.ForwardResponseMessage
|
||||
)
|
||||
31
litrpc/lit-status.proto
Normal file
31
litrpc/lit-status.proto
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
syntax = "proto3";
|
||||
|
||||
package litrpc;
|
||||
|
||||
option go_package = "github.com/lightninglabs/lightning-terminal/litrpc";
|
||||
|
||||
// The Status server can be used to query the state of various LiT sub-servers.
|
||||
service Status {
|
||||
rpc SubServerStatus (SubServerStatusReq) returns (SubServerStatusResp);
|
||||
}
|
||||
|
||||
message SubServerStatusReq {
|
||||
}
|
||||
|
||||
message SubServerStatusResp {
|
||||
// A map of sub-server names to their status.
|
||||
map<string, SubServerStatus> sub_servers = 1;
|
||||
}
|
||||
|
||||
message SubServerStatus {
|
||||
// disabled is true if the sub-server is available in the LiT package but
|
||||
// has explicitly been disabled.
|
||||
bool disabled = 1;
|
||||
|
||||
// running is true if the sub-server is currently running.
|
||||
bool running = 2;
|
||||
|
||||
// error describes an error that might have resulted in the sub-server not
|
||||
// starting up properly.
|
||||
string error = 3;
|
||||
}
|
||||
103
litrpc/lit-status.swagger.json
Normal file
103
litrpc/lit-status.swagger.json
Normal file
|
|
@ -0,0 +1,103 @@
|
|||
{
|
||||
"swagger": "2.0",
|
||||
"info": {
|
||||
"title": "lit-status.proto",
|
||||
"version": "version not set"
|
||||
},
|
||||
"tags": [
|
||||
{
|
||||
"name": "Status"
|
||||
}
|
||||
],
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"paths": {
|
||||
"/v1/status": {
|
||||
"get": {
|
||||
"operationId": "Status_SubServerStatus",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "A successful response.",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/litrpcSubServerStatusResp"
|
||||
}
|
||||
},
|
||||
"default": {
|
||||
"description": "An unexpected error response.",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/rpcStatus"
|
||||
}
|
||||
}
|
||||
},
|
||||
"tags": [
|
||||
"Status"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"definitions": {
|
||||
"litrpcSubServerStatus": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"disabled": {
|
||||
"type": "boolean",
|
||||
"description": "disabled is true if the sub-server is available in the LiT package but\nhas explicitly been disabled."
|
||||
},
|
||||
"running": {
|
||||
"type": "boolean",
|
||||
"description": "running is true if the sub-server is currently running."
|
||||
},
|
||||
"error": {
|
||||
"type": "string",
|
||||
"description": "error describes an error that might have resulted in the sub-server not\nstarting up properly."
|
||||
}
|
||||
}
|
||||
},
|
||||
"litrpcSubServerStatusResp": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"sub_servers": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"$ref": "#/definitions/litrpcSubServerStatus"
|
||||
},
|
||||
"description": "A map of sub-server names to their status."
|
||||
}
|
||||
}
|
||||
},
|
||||
"protobufAny": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"type_url": {
|
||||
"type": "string"
|
||||
},
|
||||
"value": {
|
||||
"type": "string",
|
||||
"format": "byte"
|
||||
}
|
||||
}
|
||||
},
|
||||
"rpcStatus": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"code": {
|
||||
"type": "integer",
|
||||
"format": "int32"
|
||||
},
|
||||
"message": {
|
||||
"type": "string"
|
||||
},
|
||||
"details": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/protobufAny"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
9
litrpc/lit-status.yaml
Normal file
9
litrpc/lit-status.yaml
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
type: google.api.Service
|
||||
config_version: 3
|
||||
|
||||
http:
|
||||
rules:
|
||||
|
||||
# lit-status.proto
|
||||
- selector: litrpc.Status.SubServerStatus
|
||||
get: "/v1/status"
|
||||
101
litrpc/lit-status_grpc.pb.go
Normal file
101
litrpc/lit-status_grpc.pb.go
Normal file
|
|
@ -0,0 +1,101 @@
|
|||
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
|
||||
|
||||
package litrpc
|
||||
|
||||
import (
|
||||
context "context"
|
||||
grpc "google.golang.org/grpc"
|
||||
codes "google.golang.org/grpc/codes"
|
||||
status "google.golang.org/grpc/status"
|
||||
)
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the grpc package it is being compiled against.
|
||||
// Requires gRPC-Go v1.32.0 or later.
|
||||
const _ = grpc.SupportPackageIsVersion7
|
||||
|
||||
// StatusClient is the client API for Status service.
|
||||
//
|
||||
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
|
||||
type StatusClient interface {
|
||||
SubServerStatus(ctx context.Context, in *SubServerStatusReq, opts ...grpc.CallOption) (*SubServerStatusResp, error)
|
||||
}
|
||||
|
||||
type statusClient struct {
|
||||
cc grpc.ClientConnInterface
|
||||
}
|
||||
|
||||
func NewStatusClient(cc grpc.ClientConnInterface) StatusClient {
|
||||
return &statusClient{cc}
|
||||
}
|
||||
|
||||
func (c *statusClient) SubServerStatus(ctx context.Context, in *SubServerStatusReq, opts ...grpc.CallOption) (*SubServerStatusResp, error) {
|
||||
out := new(SubServerStatusResp)
|
||||
err := c.cc.Invoke(ctx, "/litrpc.Status/SubServerStatus", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// StatusServer is the server API for Status service.
|
||||
// All implementations must embed UnimplementedStatusServer
|
||||
// for forward compatibility
|
||||
type StatusServer interface {
|
||||
SubServerStatus(context.Context, *SubServerStatusReq) (*SubServerStatusResp, error)
|
||||
mustEmbedUnimplementedStatusServer()
|
||||
}
|
||||
|
||||
// UnimplementedStatusServer must be embedded to have forward compatible implementations.
|
||||
type UnimplementedStatusServer struct {
|
||||
}
|
||||
|
||||
func (UnimplementedStatusServer) SubServerStatus(context.Context, *SubServerStatusReq) (*SubServerStatusResp, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method SubServerStatus not implemented")
|
||||
}
|
||||
func (UnimplementedStatusServer) mustEmbedUnimplementedStatusServer() {}
|
||||
|
||||
// UnsafeStatusServer may be embedded to opt out of forward compatibility for this service.
|
||||
// Use of this interface is not recommended, as added methods to StatusServer will
|
||||
// result in compilation errors.
|
||||
type UnsafeStatusServer interface {
|
||||
mustEmbedUnimplementedStatusServer()
|
||||
}
|
||||
|
||||
func RegisterStatusServer(s grpc.ServiceRegistrar, srv StatusServer) {
|
||||
s.RegisterService(&Status_ServiceDesc, srv)
|
||||
}
|
||||
|
||||
func _Status_SubServerStatus_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(SubServerStatusReq)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(StatusServer).SubServerStatus(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/litrpc.Status/SubServerStatus",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(StatusServer).SubServerStatus(ctx, req.(*SubServerStatusReq))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
// Status_ServiceDesc is the grpc.ServiceDesc for Status service.
|
||||
// It's only intended for direct use with grpc.RegisterService,
|
||||
// and not to be introspected or modified (even as a copy)
|
||||
var Status_ServiceDesc = grpc.ServiceDesc{
|
||||
ServiceName: "litrpc.Status",
|
||||
HandlerType: (*StatusServer)(nil),
|
||||
Methods: []grpc.MethodDesc{
|
||||
{
|
||||
MethodName: "SubServerStatus",
|
||||
Handler: _Status_SubServerStatus_Handler,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{},
|
||||
Metadata: "lit-status.proto",
|
||||
}
|
||||
48
litrpc/status.pb.json.go
Normal file
48
litrpc/status.pb.json.go
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
// Code generated by falafel 0.9.1. DO NOT EDIT.
|
||||
// source: lit-status.proto
|
||||
|
||||
package litrpc
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
gateway "github.com/grpc-ecosystem/grpc-gateway/v2/runtime"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/protobuf/encoding/protojson"
|
||||
)
|
||||
|
||||
func RegisterStatusJSONCallbacks(registry map[string]func(ctx context.Context,
|
||||
conn *grpc.ClientConn, reqJSON string, callback func(string, error))) {
|
||||
|
||||
marshaler := &gateway.JSONPb{
|
||||
MarshalOptions: protojson.MarshalOptions{
|
||||
UseProtoNames: true,
|
||||
EmitUnpopulated: true,
|
||||
},
|
||||
}
|
||||
|
||||
registry["litrpc.Status.SubServerStatus"] = func(ctx context.Context,
|
||||
conn *grpc.ClientConn, reqJSON string, callback func(string, error)) {
|
||||
|
||||
req := &SubServerStatusReq{}
|
||||
err := marshaler.Unmarshal([]byte(reqJSON), req)
|
||||
if err != nil {
|
||||
callback("", err)
|
||||
return
|
||||
}
|
||||
|
||||
client := NewStatusClient(conn)
|
||||
resp, err := client.SubServerStatus(ctx, req)
|
||||
if err != nil {
|
||||
callback("", err)
|
||||
return
|
||||
}
|
||||
|
||||
respBytes, err := marshaler.Marshal(resp)
|
||||
if err != nil {
|
||||
callback("", err)
|
||||
return
|
||||
}
|
||||
callback(string(respBytes), nil)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue