lnrpc: update grpc-gateway library to v2

This commit is contained in:
Oliver Gugger
2021-07-27 12:59:59 +02:00
parent 76e1223bf2
commit dd749fe580
70 changed files with 8799 additions and 8287 deletions

View File

@@ -3,7 +3,7 @@ package verrpc
import (
"context"
"github.com/grpc-ecosystem/grpc-gateway/runtime"
"github.com/grpc-ecosystem/grpc-gateway/v2/runtime"
"github.com/lightningnetwork/lnd/build"
"github.com/lightningnetwork/lnd/lnrpc"
"google.golang.org/grpc"
@@ -28,7 +28,10 @@ type ServerShell struct {
// Server is an rpc server that supports querying for information about the
// running binary.
type Server struct{}
type Server struct {
// Required by the grpc-gateway/v2 library for forward compatibility.
UnimplementedVersionerServer
}
// Start launches any helper goroutines required for the rpcServer to function.
//

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: verrpc/verrpc.proto
package verrpc
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 VersionRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
@@ -298,89 +289,3 @@ func file_verrpc_verrpc_proto_init() {
file_verrpc_verrpc_proto_goTypes = nil
file_verrpc_verrpc_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
// VersionerClient is the client API for Versioner service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
type VersionerClient interface {
// lncli: `version`
//GetVersion returns the current version and build information of the running
//daemon.
GetVersion(ctx context.Context, in *VersionRequest, opts ...grpc.CallOption) (*Version, error)
}
type versionerClient struct {
cc grpc.ClientConnInterface
}
func NewVersionerClient(cc grpc.ClientConnInterface) VersionerClient {
return &versionerClient{cc}
}
func (c *versionerClient) GetVersion(ctx context.Context, in *VersionRequest, opts ...grpc.CallOption) (*Version, error) {
out := new(Version)
err := c.cc.Invoke(ctx, "/verrpc.Versioner/GetVersion", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// VersionerServer is the server API for Versioner service.
type VersionerServer interface {
// lncli: `version`
//GetVersion returns the current version and build information of the running
//daemon.
GetVersion(context.Context, *VersionRequest) (*Version, error)
}
// UnimplementedVersionerServer can be embedded to have forward compatible implementations.
type UnimplementedVersionerServer struct {
}
func (*UnimplementedVersionerServer) GetVersion(context.Context, *VersionRequest) (*Version, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetVersion not implemented")
}
func RegisterVersionerServer(s *grpc.Server, srv VersionerServer) {
s.RegisterService(&_Versioner_serviceDesc, srv)
}
func _Versioner_GetVersion_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(VersionRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(VersionerServer).GetVersion(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/verrpc.Versioner/GetVersion",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(VersionerServer).GetVersion(ctx, req.(*VersionRequest))
}
return interceptor(ctx, in, info, handler)
}
var _Versioner_serviceDesc = grpc.ServiceDesc{
ServiceName: "verrpc.Versioner",
HandlerType: (*VersionerServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "GetVersion",
Handler: _Versioner_GetVersion_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "verrpc/verrpc.proto",
}

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_Versioner_GetVersion_0(ctx context.Context, marshaler runtime.Marshaler, client VersionerClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq VersionRequest
@@ -52,18 +52,22 @@ func local_request_Versioner_GetVersion_0(ctx context.Context, marshaler runtime
// RegisterVersionerHandlerServer registers the http handlers for service Versioner to "mux".
// UnaryRPC :call VersionerServer 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 RegisterVersionerHandlerFromEndpoint instead.
func RegisterVersionerHandlerServer(ctx context.Context, mux *runtime.ServeMux, server VersionerServer) error {
mux.Handle("GET", pattern_Versioner_GetVersion_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, "/verrpc.Versioner/GetVersion", runtime.WithHTTPPathPattern("/v2/versioner/version"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := local_request_Versioner_GetVersion_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 RegisterVersionerHandlerClient(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, "/verrpc.Versioner/GetVersion", runtime.WithHTTPPathPattern("/v2/versioner/version"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
@@ -139,7 +143,7 @@ func RegisterVersionerHandlerClient(ctx context.Context, mux *runtime.ServeMux,
}
var (
pattern_Versioner_GetVersion_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v2", "versioner", "version"}, "", runtime.AssumeColonVerbOpt(true)))
pattern_Versioner_GetVersion_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v2", "versioner", "version"}, ""))
)
var (

View File

@@ -4,6 +4,11 @@
"title": "verrpc/verrpc.proto",
"version": "version not set"
},
"tags": [
{
"name": "Versioner"
}
],
"consumes": [
"application/json"
],
@@ -14,7 +19,7 @@
"/v2/versioner/version": {
"get": {
"summary": "lncli: `version`\nGetVersion returns the current version and build information of the running\ndaemon.",
"operationId": "GetVersion",
"operationId": "Versioner_GetVersion",
"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"

View File

@@ -0,0 +1,107 @@
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
package verrpc
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
// VersionerClient is the client API for Versioner 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 VersionerClient interface {
// lncli: `version`
//GetVersion returns the current version and build information of the running
//daemon.
GetVersion(ctx context.Context, in *VersionRequest, opts ...grpc.CallOption) (*Version, error)
}
type versionerClient struct {
cc grpc.ClientConnInterface
}
func NewVersionerClient(cc grpc.ClientConnInterface) VersionerClient {
return &versionerClient{cc}
}
func (c *versionerClient) GetVersion(ctx context.Context, in *VersionRequest, opts ...grpc.CallOption) (*Version, error) {
out := new(Version)
err := c.cc.Invoke(ctx, "/verrpc.Versioner/GetVersion", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// VersionerServer is the server API for Versioner service.
// All implementations must embed UnimplementedVersionerServer
// for forward compatibility
type VersionerServer interface {
// lncli: `version`
//GetVersion returns the current version and build information of the running
//daemon.
GetVersion(context.Context, *VersionRequest) (*Version, error)
mustEmbedUnimplementedVersionerServer()
}
// UnimplementedVersionerServer must be embedded to have forward compatible implementations.
type UnimplementedVersionerServer struct {
}
func (UnimplementedVersionerServer) GetVersion(context.Context, *VersionRequest) (*Version, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetVersion not implemented")
}
func (UnimplementedVersionerServer) mustEmbedUnimplementedVersionerServer() {}
// UnsafeVersionerServer may be embedded to opt out of forward compatibility for this service.
// Use of this interface is not recommended, as added methods to VersionerServer will
// result in compilation errors.
type UnsafeVersionerServer interface {
mustEmbedUnimplementedVersionerServer()
}
func RegisterVersionerServer(s grpc.ServiceRegistrar, srv VersionerServer) {
s.RegisterService(&Versioner_ServiceDesc, srv)
}
func _Versioner_GetVersion_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(VersionRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(VersionerServer).GetVersion(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/verrpc.Versioner/GetVersion",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(VersionerServer).GetVersion(ctx, req.(*VersionRequest))
}
return interceptor(ctx, in, info, handler)
}
// Versioner_ServiceDesc is the grpc.ServiceDesc for Versioner service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
var Versioner_ServiceDesc = grpc.ServiceDesc{
ServiceName: "verrpc.Versioner",
HandlerType: (*VersionerServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "GetVersion",
Handler: _Versioner_GetVersion_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "verrpc/verrpc.proto",
}