From 73127c20d96f07a30b300840b0fb40098a1d2f52 Mon Sep 17 00:00:00 2001 From: PoAn Yang Date: Thu, 22 Feb 2024 18:13:18 +0800 Subject: [PATCH] feat: add proto Signed-off-by: PoAn Yang --- app/cmd/server.go | 7 +- generate_grpc.sh | 30 -- .../pkg/rpc/smrpc_pb2.py | 30 -- .../pkg/rpc/smrpc_pb2_grpc.py | 133 ------- pkg/client/share_manager_client.go | 2 +- pkg/rpc/server.go | 15 +- pkg/rpc/smrpc.pb.go | 328 ------------------ pkg/rpc/smrpc.proto | 15 - 8 files changed, 12 insertions(+), 548 deletions(-) delete mode 100755 generate_grpc.sh delete mode 100644 integration/rpc/share_manager/github/com/longhorn/longhorn_share_manager/pkg/rpc/smrpc_pb2.py delete mode 100644 integration/rpc/share_manager/github/com/longhorn/longhorn_share_manager/pkg/rpc/smrpc_pb2_grpc.py delete mode 100644 pkg/rpc/smrpc.pb.go delete mode 100644 pkg/rpc/smrpc.proto diff --git a/app/cmd/server.go b/app/cmd/server.go index 1d7ab19e..4810a6d3 100644 --- a/app/cmd/server.go +++ b/app/cmd/server.go @@ -9,11 +9,12 @@ import ( "github.com/sirupsen/logrus" "github.com/urfave/cli" + "github.com/longhorn/types/pkg/smrpc" "google.golang.org/grpc" healthpb "google.golang.org/grpc/health/grpc_health_v1" "google.golang.org/grpc/reflection" - smrpc "github.com/longhorn/longhorn-share-manager/pkg/rpc" + "github.com/longhorn/longhorn-share-manager/pkg/rpc" "github.com/longhorn/longhorn-share-manager/pkg/server" "github.com/longhorn/longhorn-share-manager/pkg/util" "github.com/longhorn/longhorn-share-manager/pkg/volume" @@ -126,9 +127,9 @@ func start(vol volume.Volume) error { } s := grpc.NewServer() - srv := smrpc.NewShareManagerServer(manager) + srv := rpc.NewShareManagerServer(manager) smrpc.RegisterShareManagerServiceServer(s, srv) - healthpb.RegisterHealthServer(s, smrpc.NewShareManagerHealthCheckServer(srv)) + healthpb.RegisterHealthServer(s, rpc.NewShareManagerHealthCheckServer(srv)) reflection.Register(s) logrus.Infof("Listening on share manager gRPC server %s", listenPort) diff --git a/generate_grpc.sh b/generate_grpc.sh deleted file mode 100755 index 6a5a3504..00000000 --- a/generate_grpc.sh +++ /dev/null @@ -1,30 +0,0 @@ -#!/bin/bash - -set -e - -# check and download dependency for gRPC code generate -if [ ! -e ./proto/vendor/protobuf/src/google/protobuf ]; then - rm -rf ./proto/vendor/protobuf/src/google/protobuf - DIR="./proto/vendor/protobuf/src/google/protobuf" - mkdir -p $DIR - wget https://raw.githubusercontent.com/protocolbuffers/protobuf/v24.3/src/google/protobuf/empty.proto -P $DIR -fi - -# Due to https://github.com/golang/protobuf/issues/1122, our .proto file names must be globally unique to avoid -# namespace conflicts (https://protobuf.dev/reference/go/faq/#namespace-conflict). The best way to achieve this is to -# include the whole Go import path in the name that gets compiled into the .pb.go file (e.g. -# "github.com/longhorn/backing-image-manager/pkg/rpc.proto" instead of "rpc.proto"). This formulation does the -# compilation inside a temporary directory prefixed with the full desired path before copying the .pb.go file out -# (similar to the way https://github.com/container-storage-interface/spec/blob/master/lib/go/Makefile does it). -PKG_DIR="pkg/rpc" -TMP_DIR_BASE=".protobuild" -TMP_DIR="${TMP_DIR_BASE}/github.com/longhorn/longhorn-share-manager/pkg/rpc" -mkdir -p "${TMP_DIR}" -cp "${PKG_DIR}/smrpc.proto" "${TMP_DIR}/smrpc.proto" -python3 -m grpc_tools.protoc -I "${TMP_DIR_BASE}" -I "proto/vendor/" -I "proto/vendor/protobuf/src/" --python_out=integration/rpc/share_manager --grpc_python_out=integration/rpc/share_manager "${TMP_DIR}/smrpc.proto" -mv integration/rpc/share_manager/github.com/longhorn/longhorn_share_manager/pkg/rpc/smrpc_pb2_grpc.py integration/rpc/share_manager/github/com/longhorn/longhorn_share_manager/pkg/rpc/smrpc_pb2_grpc.py -rm -rf integration/rpc/share_manager/github.com - -protoc -I "${TMP_DIR_BASE}" -I "proto/vendor/protobuf/src/" "${TMP_DIR}/smrpc.proto" --go_out=plugins=grpc:"${TMP_DIR_BASE}" -mv "${TMP_DIR_BASE}/github.com/longhorn/longhorn-share-manager/pkg/smrpc/smrpc.pb.go" "${PKG_DIR}/smrpc.pb.go" -rm -rf "${TMP_DIR_BASE}" diff --git a/integration/rpc/share_manager/github/com/longhorn/longhorn_share_manager/pkg/rpc/smrpc_pb2.py b/integration/rpc/share_manager/github/com/longhorn/longhorn_share_manager/pkg/rpc/smrpc_pb2.py deleted file mode 100644 index 99ec672e..00000000 --- a/integration/rpc/share_manager/github/com/longhorn/longhorn_share_manager/pkg/rpc/smrpc_pb2.py +++ /dev/null @@ -1,30 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by the protocol buffer compiler. DO NOT EDIT! -# source: github.com/longhorn/longhorn-share-manager/pkg/rpc/smrpc.proto -"""Generated protocol buffer code.""" -from google.protobuf import descriptor as _descriptor -from google.protobuf import descriptor_pool as _descriptor_pool -from google.protobuf import symbol_database as _symbol_database -from google.protobuf.internal import builder as _builder -# @@protoc_insertion_point(imports) - -_sym_db = _symbol_database.Default() - - -from google.protobuf import empty_pb2 as google_dot_protobuf_dot_empty__pb2 - - -DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n>github.com/longhorn/longhorn-share-manager/pkg/rpc/smrpc.proto\x1a\x1bgoogle/protobuf/empty.proto\"1\n\x15\x46ilesystemTrimRequest\x12\x18\n\x10\x65ncrypted_device\x18\x01 \x01(\x08\x32\xd1\x01\n\x13ShareManagerService\x12\x42\n\x0e\x46ilesystemTrim\x12\x16.FilesystemTrimRequest\x1a\x16.google.protobuf.Empty\"\x00\x12;\n\x07Unmount\x12\x16.google.protobuf.Empty\x1a\x16.google.protobuf.Empty\"\x00\x12\x39\n\x05Mount\x12\x16.google.protobuf.Empty\x1a\x16.google.protobuf.Empty\"\x00\x42\x36Z4github.com/longhorn/longhorn-share-manager/pkg/smrpcb\x06proto3') - -_globals = globals() -_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals) -_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'github.com.longhorn.longhorn_share_manager.pkg.rpc.smrpc_pb2', _globals) -if _descriptor._USE_C_DESCRIPTORS == False: - - DESCRIPTOR._options = None - DESCRIPTOR._serialized_options = b'Z4github.com/longhorn/longhorn-share-manager/pkg/smrpc' - _globals['_FILESYSTEMTRIMREQUEST']._serialized_start=95 - _globals['_FILESYSTEMTRIMREQUEST']._serialized_end=144 - _globals['_SHAREMANAGERSERVICE']._serialized_start=147 - _globals['_SHAREMANAGERSERVICE']._serialized_end=356 -# @@protoc_insertion_point(module_scope) diff --git a/integration/rpc/share_manager/github/com/longhorn/longhorn_share_manager/pkg/rpc/smrpc_pb2_grpc.py b/integration/rpc/share_manager/github/com/longhorn/longhorn_share_manager/pkg/rpc/smrpc_pb2_grpc.py deleted file mode 100644 index 0b6d075e..00000000 --- a/integration/rpc/share_manager/github/com/longhorn/longhorn_share_manager/pkg/rpc/smrpc_pb2_grpc.py +++ /dev/null @@ -1,133 +0,0 @@ -# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT! -"""Client and server classes corresponding to protobuf-defined services.""" -import grpc - -from github.com.longhorn.longhorn_share_manager.pkg.rpc import smrpc_pb2 as github_dot_com_dot_longhorn_dot_longhorn__share__manager_dot_pkg_dot_rpc_dot_smrpc__pb2 -from google.protobuf import empty_pb2 as google_dot_protobuf_dot_empty__pb2 - - -class ShareManagerServiceStub(object): - """Missing associated documentation comment in .proto file.""" - - def __init__(self, channel): - """Constructor. - - Args: - channel: A grpc.Channel. - """ - self.FilesystemTrim = channel.unary_unary( - '/ShareManagerService/FilesystemTrim', - request_serializer=github_dot_com_dot_longhorn_dot_longhorn__share__manager_dot_pkg_dot_rpc_dot_smrpc__pb2.FilesystemTrimRequest.SerializeToString, - response_deserializer=google_dot_protobuf_dot_empty__pb2.Empty.FromString, - ) - self.Unmount = channel.unary_unary( - '/ShareManagerService/Unmount', - request_serializer=google_dot_protobuf_dot_empty__pb2.Empty.SerializeToString, - response_deserializer=google_dot_protobuf_dot_empty__pb2.Empty.FromString, - ) - self.Mount = channel.unary_unary( - '/ShareManagerService/Mount', - request_serializer=google_dot_protobuf_dot_empty__pb2.Empty.SerializeToString, - response_deserializer=google_dot_protobuf_dot_empty__pb2.Empty.FromString, - ) - - -class ShareManagerServiceServicer(object): - """Missing associated documentation comment in .proto file.""" - - def FilesystemTrim(self, request, context): - """Missing associated documentation comment in .proto file.""" - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def Unmount(self, request, context): - """Missing associated documentation comment in .proto file.""" - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def Mount(self, request, context): - """Missing associated documentation comment in .proto file.""" - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - -def add_ShareManagerServiceServicer_to_server(servicer, server): - rpc_method_handlers = { - 'FilesystemTrim': grpc.unary_unary_rpc_method_handler( - servicer.FilesystemTrim, - request_deserializer=github_dot_com_dot_longhorn_dot_longhorn__share__manager_dot_pkg_dot_rpc_dot_smrpc__pb2.FilesystemTrimRequest.FromString, - response_serializer=google_dot_protobuf_dot_empty__pb2.Empty.SerializeToString, - ), - 'Unmount': grpc.unary_unary_rpc_method_handler( - servicer.Unmount, - request_deserializer=google_dot_protobuf_dot_empty__pb2.Empty.FromString, - response_serializer=google_dot_protobuf_dot_empty__pb2.Empty.SerializeToString, - ), - 'Mount': grpc.unary_unary_rpc_method_handler( - servicer.Mount, - request_deserializer=google_dot_protobuf_dot_empty__pb2.Empty.FromString, - response_serializer=google_dot_protobuf_dot_empty__pb2.Empty.SerializeToString, - ), - } - generic_handler = grpc.method_handlers_generic_handler( - 'ShareManagerService', rpc_method_handlers) - server.add_generic_rpc_handlers((generic_handler,)) - - - # This class is part of an EXPERIMENTAL API. -class ShareManagerService(object): - """Missing associated documentation comment in .proto file.""" - - @staticmethod - def FilesystemTrim(request, - target, - options=(), - channel_credentials=None, - call_credentials=None, - insecure=False, - compression=None, - wait_for_ready=None, - timeout=None, - metadata=None): - return grpc.experimental.unary_unary(request, target, '/ShareManagerService/FilesystemTrim', - github_dot_com_dot_longhorn_dot_longhorn__share__manager_dot_pkg_dot_rpc_dot_smrpc__pb2.FilesystemTrimRequest.SerializeToString, - google_dot_protobuf_dot_empty__pb2.Empty.FromString, - options, channel_credentials, - insecure, call_credentials, compression, wait_for_ready, timeout, metadata) - - @staticmethod - def Unmount(request, - target, - options=(), - channel_credentials=None, - call_credentials=None, - insecure=False, - compression=None, - wait_for_ready=None, - timeout=None, - metadata=None): - return grpc.experimental.unary_unary(request, target, '/ShareManagerService/Unmount', - google_dot_protobuf_dot_empty__pb2.Empty.SerializeToString, - google_dot_protobuf_dot_empty__pb2.Empty.FromString, - options, channel_credentials, - insecure, call_credentials, compression, wait_for_ready, timeout, metadata) - - @staticmethod - def Mount(request, - target, - options=(), - channel_credentials=None, - call_credentials=None, - insecure=False, - compression=None, - wait_for_ready=None, - timeout=None, - metadata=None): - return grpc.experimental.unary_unary(request, target, '/ShareManagerService/Mount', - google_dot_protobuf_dot_empty__pb2.Empty.SerializeToString, - google_dot_protobuf_dot_empty__pb2.Empty.FromString, - options, channel_credentials, - insecure, call_credentials, compression, wait_for_ready, timeout, metadata) diff --git a/pkg/client/share_manager_client.go b/pkg/client/share_manager_client.go index df7cdca7..085c8c0b 100644 --- a/pkg/client/share_manager_client.go +++ b/pkg/client/share_manager_client.go @@ -3,11 +3,11 @@ package client import ( "context" + rpc "github.com/longhorn/types/pkg/smrpc" "github.com/pkg/errors" "google.golang.org/grpc" "google.golang.org/protobuf/types/known/emptypb" - rpc "github.com/longhorn/longhorn-share-manager/pkg/rpc" "github.com/longhorn/longhorn-share-manager/pkg/types" ) diff --git a/pkg/rpc/server.go b/pkg/rpc/server.go index c7b28343..bb426a15 100644 --- a/pkg/rpc/server.go +++ b/pkg/rpc/server.go @@ -1,4 +1,4 @@ -package smrpc +package rpc import ( "fmt" @@ -8,19 +8,17 @@ import ( "time" "github.com/google/fscrypt/filesystem" + lhexec "github.com/longhorn/go-common-libs/exec" + lhtypes "github.com/longhorn/go-common-libs/types" + "github.com/longhorn/types/pkg/smrpc" "github.com/pkg/errors" "github.com/sirupsen/logrus" "golang.org/x/net/context" - - "k8s.io/mount-utils" - grpccodes "google.golang.org/grpc/codes" healthpb "google.golang.org/grpc/health/grpc_health_v1" grpcstatus "google.golang.org/grpc/status" "google.golang.org/protobuf/types/known/emptypb" - - lhexec "github.com/longhorn/go-common-libs/exec" - lhtypes "github.com/longhorn/go-common-libs/types" + "k8s.io/mount-utils" "github.com/longhorn/longhorn-share-manager/pkg/server" "github.com/longhorn/longhorn-share-manager/pkg/server/nfs" @@ -37,6 +35,7 @@ const ( ) type ShareManagerServer struct { + smrpc.UnimplementedShareManagerServiceServer sync.RWMutex logger logrus.FieldLogger @@ -50,7 +49,7 @@ func NewShareManagerServer(manager *server.ShareManager) *ShareManagerServer { } } -func (s *ShareManagerServer) FilesystemTrim(ctx context.Context, req *FilesystemTrimRequest) (resp *emptypb.Empty, err error) { +func (s *ShareManagerServer) FilesystemTrim(ctx context.Context, req *smrpc.FilesystemTrimRequest) (resp *emptypb.Empty, err error) { s.Lock() defer s.Unlock() diff --git a/pkg/rpc/smrpc.pb.go b/pkg/rpc/smrpc.pb.go deleted file mode 100644 index 5d2c65c2..00000000 --- a/pkg/rpc/smrpc.pb.go +++ /dev/null @@ -1,328 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.26.0 -// protoc v4.24.3 -// source: github.com/longhorn/longhorn-share-manager/pkg/rpc/smrpc.proto - -package smrpc - -import ( - context "context" - 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" - emptypb "google.golang.org/protobuf/types/known/emptypb" - 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 FilesystemTrimRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - EncryptedDevice bool `protobuf:"varint,1,opt,name=encrypted_device,json=encryptedDevice,proto3" json:"encrypted_device,omitempty"` -} - -func (x *FilesystemTrimRequest) Reset() { - *x = FilesystemTrimRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_github_com_longhorn_longhorn_share_manager_pkg_rpc_smrpc_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *FilesystemTrimRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*FilesystemTrimRequest) ProtoMessage() {} - -func (x *FilesystemTrimRequest) ProtoReflect() protoreflect.Message { - mi := &file_github_com_longhorn_longhorn_share_manager_pkg_rpc_smrpc_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 FilesystemTrimRequest.ProtoReflect.Descriptor instead. -func (*FilesystemTrimRequest) Descriptor() ([]byte, []int) { - return file_github_com_longhorn_longhorn_share_manager_pkg_rpc_smrpc_proto_rawDescGZIP(), []int{0} -} - -func (x *FilesystemTrimRequest) GetEncryptedDevice() bool { - if x != nil { - return x.EncryptedDevice - } - return false -} - -var File_github_com_longhorn_longhorn_share_manager_pkg_rpc_smrpc_proto protoreflect.FileDescriptor - -var file_github_com_longhorn_longhorn_share_manager_pkg_rpc_smrpc_proto_rawDesc = []byte{ - 0x0a, 0x3e, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6c, 0x6f, 0x6e, - 0x67, 0x68, 0x6f, 0x72, 0x6e, 0x2f, 0x6c, 0x6f, 0x6e, 0x67, 0x68, 0x6f, 0x72, 0x6e, 0x2d, 0x73, - 0x68, 0x61, 0x72, 0x65, 0x2d, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x2f, 0x70, 0x6b, 0x67, - 0x2f, 0x72, 0x70, 0x63, 0x2f, 0x73, 0x6d, 0x72, 0x70, 0x63, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x1a, 0x1b, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, - 0x66, 0x2f, 0x65, 0x6d, 0x70, 0x74, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x42, 0x0a, - 0x15, 0x46, 0x69, 0x6c, 0x65, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x54, 0x72, 0x69, 0x6d, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x29, 0x0a, 0x10, 0x65, 0x6e, 0x63, 0x72, 0x79, 0x70, - 0x74, 0x65, 0x64, 0x5f, 0x64, 0x65, 0x76, 0x69, 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, - 0x52, 0x0f, 0x65, 0x6e, 0x63, 0x72, 0x79, 0x70, 0x74, 0x65, 0x64, 0x44, 0x65, 0x76, 0x69, 0x63, - 0x65, 0x32, 0xd1, 0x01, 0x0a, 0x13, 0x53, 0x68, 0x61, 0x72, 0x65, 0x4d, 0x61, 0x6e, 0x61, 0x67, - 0x65, 0x72, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x42, 0x0a, 0x0e, 0x46, 0x69, 0x6c, - 0x65, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x54, 0x72, 0x69, 0x6d, 0x12, 0x16, 0x2e, 0x46, 0x69, - 0x6c, 0x65, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x54, 0x72, 0x69, 0x6d, 0x52, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x00, 0x12, 0x3b, 0x0a, - 0x07, 0x55, 0x6e, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, - 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, - 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, - 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x00, 0x12, 0x39, 0x0a, 0x05, 0x4d, 0x6f, - 0x75, 0x6e, 0x74, 0x12, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x16, 0x2e, 0x67, 0x6f, - 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, - 0x70, 0x74, 0x79, 0x22, 0x00, 0x42, 0x36, 0x5a, 0x34, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, - 0x63, 0x6f, 0x6d, 0x2f, 0x6c, 0x6f, 0x6e, 0x67, 0x68, 0x6f, 0x72, 0x6e, 0x2f, 0x6c, 0x6f, 0x6e, - 0x67, 0x68, 0x6f, 0x72, 0x6e, 0x2d, 0x73, 0x68, 0x61, 0x72, 0x65, 0x2d, 0x6d, 0x61, 0x6e, 0x61, - 0x67, 0x65, 0x72, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x73, 0x6d, 0x72, 0x70, 0x63, 0x62, 0x06, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x33, -} - -var ( - file_github_com_longhorn_longhorn_share_manager_pkg_rpc_smrpc_proto_rawDescOnce sync.Once - file_github_com_longhorn_longhorn_share_manager_pkg_rpc_smrpc_proto_rawDescData = file_github_com_longhorn_longhorn_share_manager_pkg_rpc_smrpc_proto_rawDesc -) - -func file_github_com_longhorn_longhorn_share_manager_pkg_rpc_smrpc_proto_rawDescGZIP() []byte { - file_github_com_longhorn_longhorn_share_manager_pkg_rpc_smrpc_proto_rawDescOnce.Do(func() { - file_github_com_longhorn_longhorn_share_manager_pkg_rpc_smrpc_proto_rawDescData = protoimpl.X.CompressGZIP(file_github_com_longhorn_longhorn_share_manager_pkg_rpc_smrpc_proto_rawDescData) - }) - return file_github_com_longhorn_longhorn_share_manager_pkg_rpc_smrpc_proto_rawDescData -} - -var file_github_com_longhorn_longhorn_share_manager_pkg_rpc_smrpc_proto_msgTypes = make([]protoimpl.MessageInfo, 1) -var file_github_com_longhorn_longhorn_share_manager_pkg_rpc_smrpc_proto_goTypes = []interface{}{ - (*FilesystemTrimRequest)(nil), // 0: FilesystemTrimRequest - (*emptypb.Empty)(nil), // 1: google.protobuf.Empty -} -var file_github_com_longhorn_longhorn_share_manager_pkg_rpc_smrpc_proto_depIdxs = []int32{ - 0, // 0: ShareManagerService.FilesystemTrim:input_type -> FilesystemTrimRequest - 1, // 1: ShareManagerService.Unmount:input_type -> google.protobuf.Empty - 1, // 2: ShareManagerService.Mount:input_type -> google.protobuf.Empty - 1, // 3: ShareManagerService.FilesystemTrim:output_type -> google.protobuf.Empty - 1, // 4: ShareManagerService.Unmount:output_type -> google.protobuf.Empty - 1, // 5: ShareManagerService.Mount:output_type -> google.protobuf.Empty - 3, // [3:6] is the sub-list for method output_type - 0, // [0:3] is the sub-list for method input_type - 0, // [0:0] is the sub-list for extension type_name - 0, // [0:0] is the sub-list for extension extendee - 0, // [0:0] is the sub-list for field type_name -} - -func init() { file_github_com_longhorn_longhorn_share_manager_pkg_rpc_smrpc_proto_init() } -func file_github_com_longhorn_longhorn_share_manager_pkg_rpc_smrpc_proto_init() { - if File_github_com_longhorn_longhorn_share_manager_pkg_rpc_smrpc_proto != nil { - return - } - if !protoimpl.UnsafeEnabled { - file_github_com_longhorn_longhorn_share_manager_pkg_rpc_smrpc_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*FilesystemTrimRequest); 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_github_com_longhorn_longhorn_share_manager_pkg_rpc_smrpc_proto_rawDesc, - NumEnums: 0, - NumMessages: 1, - NumExtensions: 0, - NumServices: 1, - }, - GoTypes: file_github_com_longhorn_longhorn_share_manager_pkg_rpc_smrpc_proto_goTypes, - DependencyIndexes: file_github_com_longhorn_longhorn_share_manager_pkg_rpc_smrpc_proto_depIdxs, - MessageInfos: file_github_com_longhorn_longhorn_share_manager_pkg_rpc_smrpc_proto_msgTypes, - }.Build() - File_github_com_longhorn_longhorn_share_manager_pkg_rpc_smrpc_proto = out.File - file_github_com_longhorn_longhorn_share_manager_pkg_rpc_smrpc_proto_rawDesc = nil - file_github_com_longhorn_longhorn_share_manager_pkg_rpc_smrpc_proto_goTypes = nil - file_github_com_longhorn_longhorn_share_manager_pkg_rpc_smrpc_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 - -// ShareManagerServiceClient is the client API for ShareManagerService service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. -type ShareManagerServiceClient interface { - FilesystemTrim(ctx context.Context, in *FilesystemTrimRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) - Unmount(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*emptypb.Empty, error) - Mount(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*emptypb.Empty, error) -} - -type shareManagerServiceClient struct { - cc grpc.ClientConnInterface -} - -func NewShareManagerServiceClient(cc grpc.ClientConnInterface) ShareManagerServiceClient { - return &shareManagerServiceClient{cc} -} - -func (c *shareManagerServiceClient) FilesystemTrim(ctx context.Context, in *FilesystemTrimRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) { - out := new(emptypb.Empty) - err := c.cc.Invoke(ctx, "/ShareManagerService/FilesystemTrim", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *shareManagerServiceClient) Unmount(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*emptypb.Empty, error) { - out := new(emptypb.Empty) - err := c.cc.Invoke(ctx, "/ShareManagerService/Unmount", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *shareManagerServiceClient) Mount(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*emptypb.Empty, error) { - out := new(emptypb.Empty) - err := c.cc.Invoke(ctx, "/ShareManagerService/Mount", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -// ShareManagerServiceServer is the server API for ShareManagerService service. -type ShareManagerServiceServer interface { - FilesystemTrim(context.Context, *FilesystemTrimRequest) (*emptypb.Empty, error) - Unmount(context.Context, *emptypb.Empty) (*emptypb.Empty, error) - Mount(context.Context, *emptypb.Empty) (*emptypb.Empty, error) -} - -// UnimplementedShareManagerServiceServer can be embedded to have forward compatible implementations. -type UnimplementedShareManagerServiceServer struct { -} - -func (*UnimplementedShareManagerServiceServer) FilesystemTrim(context.Context, *FilesystemTrimRequest) (*emptypb.Empty, error) { - return nil, status.Errorf(codes.Unimplemented, "method FilesystemTrim not implemented") -} -func (*UnimplementedShareManagerServiceServer) Unmount(context.Context, *emptypb.Empty) (*emptypb.Empty, error) { - return nil, status.Errorf(codes.Unimplemented, "method Unmount not implemented") -} -func (*UnimplementedShareManagerServiceServer) Mount(context.Context, *emptypb.Empty) (*emptypb.Empty, error) { - return nil, status.Errorf(codes.Unimplemented, "method Mount not implemented") -} - -func RegisterShareManagerServiceServer(s *grpc.Server, srv ShareManagerServiceServer) { - s.RegisterService(&_ShareManagerService_serviceDesc, srv) -} - -func _ShareManagerService_FilesystemTrim_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(FilesystemTrimRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(ShareManagerServiceServer).FilesystemTrim(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/ShareManagerService/FilesystemTrim", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(ShareManagerServiceServer).FilesystemTrim(ctx, req.(*FilesystemTrimRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _ShareManagerService_Unmount_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(emptypb.Empty) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(ShareManagerServiceServer).Unmount(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/ShareManagerService/Unmount", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(ShareManagerServiceServer).Unmount(ctx, req.(*emptypb.Empty)) - } - return interceptor(ctx, in, info, handler) -} - -func _ShareManagerService_Mount_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(emptypb.Empty) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(ShareManagerServiceServer).Mount(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/ShareManagerService/Mount", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(ShareManagerServiceServer).Mount(ctx, req.(*emptypb.Empty)) - } - return interceptor(ctx, in, info, handler) -} - -var _ShareManagerService_serviceDesc = grpc.ServiceDesc{ - ServiceName: "ShareManagerService", - HandlerType: (*ShareManagerServiceServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "FilesystemTrim", - Handler: _ShareManagerService_FilesystemTrim_Handler, - }, - { - MethodName: "Unmount", - Handler: _ShareManagerService_Unmount_Handler, - }, - { - MethodName: "Mount", - Handler: _ShareManagerService_Mount_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "github.com/longhorn/longhorn-share-manager/pkg/rpc/smrpc.proto", -} diff --git a/pkg/rpc/smrpc.proto b/pkg/rpc/smrpc.proto deleted file mode 100644 index 73b3c949..00000000 --- a/pkg/rpc/smrpc.proto +++ /dev/null @@ -1,15 +0,0 @@ -syntax="proto3"; - -option go_package = "github.com/longhorn/longhorn-share-manager/pkg/smrpc"; - -import "google/protobuf/empty.proto"; - -service ShareManagerService { - rpc FilesystemTrim(FilesystemTrimRequest) returns (google.protobuf.Empty) {} - rpc Unmount(google.protobuf.Empty) returns (google.protobuf.Empty) {} - rpc Mount(google.protobuf.Empty) returns (google.protobuf.Empty) {} -} - -message FilesystemTrimRequest { - bool encrypted_device = 1; -}