lnrpc: update grpc-gateway library to v2

This commit is contained in:
Oliver Gugger committed 2021-07-27 13:09:59 +02:00
1 parent 76e1223bf2
commit dd749fe580
70 files changed
+8799 -8287

No files matched your search

+5 -2
View File
@@ -7,7 +7,7 @@ import (
"errors"
"fmt"
"github.com/grpc-ecosystem/grpc-gateway/runtime"
"github.com/grpc-ecosystem/grpc-gateway/v2/runtime"
"github.com/lightningnetwork/lnd/lnrpc"
"google.golang.org/grpc"
"gopkg.in/macaroon-bakery.v2/bakery"
@@ -45,6 +45,9 @@ type ServerShell struct {
// Handler is the RPC server we'll use to interact with the backing active
// watchtower.
type Handler struct {
// Required by the grpc-gateway/v2 library for forward compatibility.
UnimplementedWatchtowerServer
cfg Config
}
@@ -58,7 +61,7 @@ var _ WatchtowerServer = (*Handler)(nil)
// on start up. If we're unable to locate, or create the macaroons we need, then
// we'll return with an error.
func New(cfg *Config) (*Handler, lnrpc.MacaroonPerms, error) {
return &Handler{*cfg}, macPermissions, nil
return &Handler{cfg: *cfg}, macPermissions, nil
}
// Start launches any helper goroutines required for the Handler to function.
+1 -98
View File
@@ -1,17 +1,12 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.23.0
// protoc-gen-go v1.26.0
// protoc v3.6.1
// source: watchtowerrpc/watchtower.proto
package watchtowerrpc
import (
context "context"
proto "github.com/golang/protobuf/proto"
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
@@ -25,10 +20,6 @@ const (
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
// This is a compile-time assertion that a sufficiently up-to-date version
// of the legacy proto package is being used.
const _ = proto.ProtoPackageIsVersion4
type GetInfoRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
@@ -235,91 +226,3 @@ func file_watchtowerrpc_watchtower_proto_init() {
file_watchtowerrpc_watchtower_proto_goTypes = nil
file_watchtowerrpc_watchtower_proto_depIdxs = nil
}
// Reference imports to suppress errors if they are not otherwise used.
var _ context.Context
var _ grpc.ClientConnInterface
// 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.SupportPackageIsVersion6
// WatchtowerClient is the client API for Watchtower service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
type WatchtowerClient interface {
// lncli: tower info
//GetInfo returns general information concerning the companion watchtower
//including its public key and URIs where the server is currently
//listening for clients.
GetInfo(ctx context.Context, in *GetInfoRequest, opts ...grpc.CallOption) (*GetInfoResponse, error)
}
type watchtowerClient struct {
cc grpc.ClientConnInterface
}
func NewWatchtowerClient(cc grpc.ClientConnInterface) WatchtowerClient {
return &watchtowerClient{cc}
}
func (c *watchtowerClient) GetInfo(ctx context.Context, in *GetInfoRequest, opts ...grpc.CallOption) (*GetInfoResponse, error) {
out := new(GetInfoResponse)
err := c.cc.Invoke(ctx, "/watchtowerrpc.Watchtower/GetInfo", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// WatchtowerServer is the server API for Watchtower service.
type WatchtowerServer interface {
// lncli: tower info
//GetInfo returns general information concerning the companion watchtower
//including its public key and URIs where the server is currently
//listening for clients.
GetInfo(context.Context, *GetInfoRequest) (*GetInfoResponse, error)
}
// UnimplementedWatchtowerServer can be embedded to have forward compatible implementations.
type UnimplementedWatchtowerServer struct {
}
func (*UnimplementedWatchtowerServer) GetInfo(context.Context, *GetInfoRequest) (*GetInfoResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetInfo not implemented")
}
func RegisterWatchtowerServer(s *grpc.Server, srv WatchtowerServer) {
s.RegisterService(&_Watchtower_serviceDesc, srv)
}
func _Watchtower_GetInfo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(GetInfoRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(WatchtowerServer).GetInfo(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/watchtowerrpc.Watchtower/GetInfo",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(WatchtowerServer).GetInfo(ctx, req.(*GetInfoRequest))
}
return interceptor(ctx, in, info, handler)
}
var _Watchtower_serviceDesc = grpc.ServiceDesc{
ServiceName: "watchtowerrpc.Watchtower",
HandlerType: (*WatchtowerServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "GetInfo",
Handler: _Watchtower_GetInfo_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "watchtowerrpc/watchtower.proto",
}
+12 -8
View File
@@ -13,14 +13,14 @@ import (
"io"
"net/http"
"github.com/golang/protobuf/descriptor"
"github.com/golang/protobuf/proto"
"github.com/grpc-ecosystem/grpc-gateway/runtime"
"github.com/grpc-ecosystem/grpc-gateway/utilities"
"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
@@ -29,7 +29,7 @@ var _ io.Reader
var _ status.Status
var _ = runtime.String
var _ = utilities.NewDoubleArray
var _ = descriptor.ForMessage
var _ = metadata.Join
func request_Watchtower_GetInfo_0(ctx context.Context, marshaler runtime.Marshaler, client WatchtowerClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq GetInfoRequest
@@ -52,18 +52,22 @@ func local_request_Watchtower_GetInfo_0(ctx context.Context, marshaler runtime.M
// RegisterWatchtowerHandlerServer registers the http handlers for service Watchtower to "mux".
// UnaryRPC :call WatchtowerServer 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 RegisterWatchtowerHandlerFromEndpoint instead.
func RegisterWatchtowerHandlerServer(ctx context.Context, mux *runtime.ServeMux, server WatchtowerServer) error {
mux.Handle("GET", pattern_Watchtower_GetInfo_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)
rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/watchtowerrpc.Watchtower/GetInfo", runtime.WithHTTPPathPattern("/v2/watchtower/server"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := local_request_Watchtower_GetInfo_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)
@@ -119,7 +123,7 @@ func RegisterWatchtowerHandlerClient(ctx context.Context, mux *runtime.ServeMux,
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
rctx, err := runtime.AnnotateContext(ctx, mux, req)
rctx, err := runtime.AnnotateContext(ctx, mux, req, "/watchtowerrpc.Watchtower/GetInfo", runtime.WithHTTPPathPattern("/v2/watchtower/server"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
@@ -139,7 +143,7 @@ func RegisterWatchtowerHandlerClient(ctx context.Context, mux *runtime.ServeMux,
}
var (
pattern_Watchtower_GetInfo_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v2", "watchtower", "server"}, "", runtime.AssumeColonVerbOpt(true)))
pattern_Watchtower_GetInfo_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v2", "watchtower", "server"}, ""))
)
var (
+9 -7
View File
@@ -4,6 +4,11 @@
"title": "watchtowerrpc/watchtower.proto",
"version": "version not set"
},
"tags": [
{
"name": "Watchtower"
}
],
"consumes": [
"application/json"
],
@@ -14,7 +19,7 @@
"/v2/watchtower/server": {
"get": {
"summary": "lncli: tower info\nGetInfo returns general information concerning the companion watchtower\nincluding its public key and URIs where the server is currently\nlistening for clients.",
"operationId": "GetInfo",
"operationId": "Watchtower_GetInfo",
"responses": {
"200": {
"description": "A successful response.",
@@ -23,9 +28,9 @@
}
},
"default": {
"description": "An unexpected error response",
"description": "An unexpected error response.",
"schema": {
"$ref": "#/definitions/runtimeError"
"$ref": "#/definitions/rpcStatus"
}
}
},
@@ -48,12 +53,9 @@
}
}
},
"runtimeError": {
"rpcStatus": {
"type": "object",
"properties": {
"error": {
"type": "string"
},
"code": {
"type": "integer",
"format": "int32"
+109
View File
@@ -0,0 +1,109 @@
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
package watchtowerrpc
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
// WatchtowerClient is the client API for Watchtower 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 WatchtowerClient interface {
// lncli: tower info
//GetInfo returns general information concerning the companion watchtower
//including its public key and URIs where the server is currently
//listening for clients.
GetInfo(ctx context.Context, in *GetInfoRequest, opts ...grpc.CallOption) (*GetInfoResponse, error)
}
type watchtowerClient struct {
cc grpc.ClientConnInterface
}
func NewWatchtowerClient(cc grpc.ClientConnInterface) WatchtowerClient {
return &watchtowerClient{cc}
}
func (c *watchtowerClient) GetInfo(ctx context.Context, in *GetInfoRequest, opts ...grpc.CallOption) (*GetInfoResponse, error) {
out := new(GetInfoResponse)
err := c.cc.Invoke(ctx, "/watchtowerrpc.Watchtower/GetInfo", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// WatchtowerServer is the server API for Watchtower service.
// All implementations must embed UnimplementedWatchtowerServer
// for forward compatibility
type WatchtowerServer interface {
// lncli: tower info
//GetInfo returns general information concerning the companion watchtower
//including its public key and URIs where the server is currently
//listening for clients.
GetInfo(context.Context, *GetInfoRequest) (*GetInfoResponse, error)
mustEmbedUnimplementedWatchtowerServer()
}
// UnimplementedWatchtowerServer must be embedded to have forward compatible implementations.
type UnimplementedWatchtowerServer struct {
}
func (UnimplementedWatchtowerServer) GetInfo(context.Context, *GetInfoRequest) (*GetInfoResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetInfo not implemented")
}
func (UnimplementedWatchtowerServer) mustEmbedUnimplementedWatchtowerServer() {}
// UnsafeWatchtowerServer may be embedded to opt out of forward compatibility for this service.
// Use of this interface is not recommended, as added methods to WatchtowerServer will
// result in compilation errors.
type UnsafeWatchtowerServer interface {
mustEmbedUnimplementedWatchtowerServer()
}
func RegisterWatchtowerServer(s grpc.ServiceRegistrar, srv WatchtowerServer) {
s.RegisterService(&Watchtower_ServiceDesc, srv)
}
func _Watchtower_GetInfo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(GetInfoRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(WatchtowerServer).GetInfo(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/watchtowerrpc.Watchtower/GetInfo",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(WatchtowerServer).GetInfo(ctx, req.(*GetInfoRequest))
}
return interceptor(ctx, in, info, handler)
}
// Watchtower_ServiceDesc is the grpc.ServiceDesc for Watchtower service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
var Watchtower_ServiceDesc = grpc.ServiceDesc{
ServiceName: "watchtowerrpc.Watchtower",
HandlerType: (*WatchtowerServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "GetInfo",
Handler: _Watchtower_GetInfo_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "watchtowerrpc/watchtower.proto",
}