From 954d83160e663c236b7759a2779de52fd9652199 Mon Sep 17 00:00:00 2001 From: Ahmad Sherif Date: Tue, 30 Jan 2018 20:51:28 +0100 Subject: [PATCH] Update GetBlobs RPC to retrieve blobs by revision/path pairs Closes gitaly#983 --- blob.proto | 23 +++-- go/blob.pb.go | 131 ++++++++++++++++++++-------- ruby/lib/gitaly/blob_pb.rb | 11 ++- ruby/lib/gitaly/blob_services_pb.rb | 4 - 4 files changed, 117 insertions(+), 52 deletions(-) diff --git a/blob.proto b/blob.proto index 36e05c5a..e03359d6 100644 --- a/blob.proto +++ b/blob.proto @@ -9,10 +9,6 @@ service BlobService { // ID. We use a stream to return a chunked arbitrarily large binary // response rpc GetBlob(GetBlobRequest) returns (stream GetBlobResponse) {} - // GetBlobsBySHA returns the contents of a blob objects referenced by their object - // ID. We use a stream to return a chunked arbitrarily large binary response. - // The blobs are sent in a continous stream, the caller is responsible for spliting - // them up into multiple blobs by their object IDs. rpc GetBlobs(GetBlobsRequest) returns (stream GetBlobsResponse) {} rpc GetLFSPointers(GetLFSPointersRequest) returns (stream GetLFSPointersResponse) {} } @@ -35,20 +31,29 @@ message GetBlobResponse { } message GetBlobsRequest { + message RevisionPath { + string revision = 1; + bytes path = 2; + } + Repository repository = 1; - // Object IDs (SHA1) of the blobs we want to get - repeated string oids = 2; + // Revision/Path pairs of the blobs we want to get. + repeated RevisionPath revision_paths = 2; // Maximum number of bytes we want to receive. Use '-1' to get the full blobs no matter how big. int64 limit = 3; } message GetBlobsResponse { // Blob size; present only on the first message per blob - int64 size = 1; - // Chunk of blob data - bytes data = 2; + int64 size = 1; + // Chunk of blob data, could span over multiple messages. + bytes data = 2; // Object ID of the current blob. Only present on the first message per blob. Empty if no blob was found. string oid = 3; + bool is_submodule = 4; + int32 mode = 5; + string revision = 6; + bytes path = 7; } message LFSPointer { diff --git a/go/blob.pb.go b/go/blob.pb.go index e12ca0f0..58602574 100644 --- a/go/blob.pb.go +++ b/go/blob.pb.go @@ -333,8 +333,8 @@ func (m *GetBlobResponse) GetOid() string { type GetBlobsRequest struct { Repository *Repository `protobuf:"bytes,1,opt,name=repository" json:"repository,omitempty"` - // Object IDs (SHA1) of the blobs we want to get - Oids []string `protobuf:"bytes,2,rep,name=oids" json:"oids,omitempty"` + // Revision/Path pairs of the blobs we want to get. + RevisionPaths []*GetBlobsRequest_RevisionPath `protobuf:"bytes,2,rep,name=revision_paths,json=revisionPaths" json:"revision_paths,omitempty"` // Maximum number of bytes we want to receive. Use '-1' to get the full blobs no matter how big. Limit int64 `protobuf:"varint,3,opt,name=limit" json:"limit,omitempty"` } @@ -351,9 +351,9 @@ func (m *GetBlobsRequest) GetRepository() *Repository { return nil } -func (m *GetBlobsRequest) GetOids() []string { +func (m *GetBlobsRequest) GetRevisionPaths() []*GetBlobsRequest_RevisionPath { if m != nil { - return m.Oids + return m.RevisionPaths } return nil } @@ -365,13 +365,41 @@ func (m *GetBlobsRequest) GetLimit() int64 { return 0 } +type GetBlobsRequest_RevisionPath struct { + Revision string `protobuf:"bytes,1,opt,name=revision" json:"revision,omitempty"` + Path []byte `protobuf:"bytes,2,opt,name=path,proto3" json:"path,omitempty"` +} + +func (m *GetBlobsRequest_RevisionPath) Reset() { *m = GetBlobsRequest_RevisionPath{} } +func (m *GetBlobsRequest_RevisionPath) String() string { return proto.CompactTextString(m) } +func (*GetBlobsRequest_RevisionPath) ProtoMessage() {} +func (*GetBlobsRequest_RevisionPath) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{2, 0} } + +func (m *GetBlobsRequest_RevisionPath) GetRevision() string { + if m != nil { + return m.Revision + } + return "" +} + +func (m *GetBlobsRequest_RevisionPath) GetPath() []byte { + if m != nil { + return m.Path + } + return nil +} + type GetBlobsResponse struct { // Blob size; present only on the first message per blob Size int64 `protobuf:"varint,1,opt,name=size" json:"size,omitempty"` - // Chunk of blob data + // Chunk of blob data, could span over multiple messages. Data []byte `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"` // Object ID of the current blob. Only present on the first message per blob. Empty if no blob was found. - Oid string `protobuf:"bytes,3,opt,name=oid" json:"oid,omitempty"` + Oid string `protobuf:"bytes,3,opt,name=oid" json:"oid,omitempty"` + IsSubmodule bool `protobuf:"varint,4,opt,name=is_submodule,json=isSubmodule" json:"is_submodule,omitempty"` + Mode int32 `protobuf:"varint,5,opt,name=mode" json:"mode,omitempty"` + Revision string `protobuf:"bytes,6,opt,name=revision" json:"revision,omitempty"` + Path []byte `protobuf:"bytes,7,opt,name=path,proto3" json:"path,omitempty"` } func (m *GetBlobsResponse) Reset() { *m = GetBlobsResponse{} } @@ -400,6 +428,34 @@ func (m *GetBlobsResponse) GetOid() string { return "" } +func (m *GetBlobsResponse) GetIsSubmodule() bool { + if m != nil { + return m.IsSubmodule + } + return false +} + +func (m *GetBlobsResponse) GetMode() int32 { + if m != nil { + return m.Mode + } + return 0 +} + +func (m *GetBlobsResponse) GetRevision() string { + if m != nil { + return m.Revision + } + return "" +} + +func (m *GetBlobsResponse) GetPath() []byte { + if m != nil { + return m.Path + } + return nil +} + type LFSPointer struct { Size int64 `protobuf:"varint,1,opt,name=size" json:"size,omitempty"` Data []byte `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"` @@ -476,6 +532,7 @@ func init() { proto.RegisterType((*GetBlobRequest)(nil), "gitaly.GetBlobRequest") proto.RegisterType((*GetBlobResponse)(nil), "gitaly.GetBlobResponse") proto.RegisterType((*GetBlobsRequest)(nil), "gitaly.GetBlobsRequest") + proto.RegisterType((*GetBlobsRequest_RevisionPath)(nil), "gitaly.GetBlobsRequest.RevisionPath") proto.RegisterType((*GetBlobsResponse)(nil), "gitaly.GetBlobsResponse") proto.RegisterType((*LFSPointer)(nil), "gitaly.LFSPointer") proto.RegisterType((*GetLFSPointersRequest)(nil), "gitaly.GetLFSPointersRequest") @@ -497,10 +554,6 @@ type BlobServiceClient interface { // ID. We use a stream to return a chunked arbitrarily large binary // response GetBlob(ctx context.Context, in *GetBlobRequest, opts ...grpc.CallOption) (BlobService_GetBlobClient, error) - // GetBlobsBySHA returns the contents of a blob objects referenced by their object - // ID. We use a stream to return a chunked arbitrarily large binary response. - // The blobs are sent in a continous stream, the caller is responsible for spliting - // them up into multiple blobs by their object IDs. GetBlobs(ctx context.Context, in *GetBlobsRequest, opts ...grpc.CallOption) (BlobService_GetBlobsClient, error) GetLFSPointers(ctx context.Context, in *GetLFSPointersRequest, opts ...grpc.CallOption) (BlobService_GetLFSPointersClient, error) } @@ -616,10 +669,6 @@ type BlobServiceServer interface { // ID. We use a stream to return a chunked arbitrarily large binary // response GetBlob(*GetBlobRequest, BlobService_GetBlobServer) error - // GetBlobsBySHA returns the contents of a blob objects referenced by their object - // ID. We use a stream to return a chunked arbitrarily large binary response. - // The blobs are sent in a continous stream, the caller is responsible for spliting - // them up into multiple blobs by their object IDs. GetBlobs(*GetBlobsRequest, BlobService_GetBlobsServer) error GetLFSPointers(*GetLFSPointersRequest, BlobService_GetLFSPointersServer) error } @@ -718,28 +767,34 @@ var _BlobService_serviceDesc = grpc.ServiceDesc{ func init() { proto.RegisterFile("blob.proto", fileDescriptor0) } var fileDescriptor0 = []byte{ - // 353 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x53, 0xcd, 0x4e, 0xe3, 0x30, - 0x10, 0x5e, 0xd7, 0xdd, 0xfe, 0x4c, 0xab, 0xdd, 0x6a, 0xb4, 0x5b, 0x42, 0x24, 0x50, 0x94, 0x53, - 0x4e, 0x15, 0x2a, 0xe2, 0x8a, 0x04, 0x87, 0x56, 0x88, 0x4a, 0x20, 0xf7, 0x01, 0xaa, 0x84, 0xb8, - 0x60, 0xc9, 0xd4, 0x21, 0x36, 0x48, 0xe5, 0x7d, 0x79, 0x0f, 0x14, 0xa7, 0xf9, 0xa1, 0x55, 0x4f, - 0xb9, 0x8d, 0x67, 0xe6, 0xfb, 0xc9, 0x17, 0x1b, 0x20, 0x92, 0x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 0xaf, 0x92, 0x5d, 0xdf, 0x21, 0x1e, 0xad, 0x4b, 0x55, 0x10, 0x36, 0x90, 0x6b, 0x5d, 0xc0, 0xa7, - 0x5f, 0x04, 0x06, 0x59, 0x98, 0x4b, 0x9e, 0x7e, 0x88, 0x27, 0x8e, 0xd7, 0xd0, 0xdd, 0xc5, 0x8b, - 0xe3, 0x02, 0xfb, 0xf3, 0x6e, 0xba, 0x27, 0x07, 0xfd, 0xdc, 0x82, 0xff, 0xeb, 0x82, 0xe0, 0x0d, - 0xf4, 0x8a, 0xdf, 0x83, 0xfb, 0x8b, 0x45, 0x28, 0xae, 0x73, 0x38, 0xa8, 0x51, 0x2c, 0xed, 0x6b, - 0xa8, 0x7d, 0x23, 0x9e, 0xd5, 0xf6, 0x0f, 0x33, 0x76, 0xcf, 0x8f, 0x8d, 0x2b, 0xd2, 0xa8, 0x63, - 0x5f, 0xda, 0xe5, 0x77, 0x00, 0x00, 0x00, 0xff, 0xff, 0xeb, 0x6b, 0x28, 0x11, 0x8d, 0x03, 0x00, - 0x00, + // 451 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x54, 0xcd, 0x8e, 0xd3, 0x30, + 0x10, 0xc6, 0x9b, 0xed, 0xdf, 0x24, 0x2c, 0x2b, 0x0b, 0x76, 0x43, 0x24, 0x50, 0x88, 0x38, 0xe4, + 0x54, 0xa1, 0x22, 0xae, 0x2b, 0xc1, 0x61, 0x57, 0x68, 0x91, 0x58, 0xb9, 0x0f, 0x50, 0x25, 0xc4, + 0xa5, 0x96, 0xdc, 0x3a, 0x78, 0xdc, 0x95, 0xca, 0x6b, 0xf1, 0x4c, 0x48, 0x3c, 0x06, 0xb2, 0xf3, + 0xd3, 0xd0, 0xd2, 0x53, 0x6e, 0x33, 0x63, 0x7f, 0x3f, 0xe3, 0x99, 0x04, 0x20, 0x97, 0x2a, 0x9f, + 0x96, 0x5a, 0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x73, 0x6f, + 0x04, 0x00, 0x00, } diff --git a/ruby/lib/gitaly/blob_pb.rb b/ruby/lib/gitaly/blob_pb.rb index c2e71aa7..fdb6df20 100644 --- a/ruby/lib/gitaly/blob_pb.rb +++ b/ruby/lib/gitaly/blob_pb.rb @@ -17,13 +17,21 @@ Google::Protobuf::DescriptorPool.generated_pool.build do end add_message "gitaly.GetBlobsRequest" do optional :repository, :message, 1, "gitaly.Repository" - repeated :oids, :string, 2 + repeated :revision_paths, :message, 2, "gitaly.GetBlobsRequest.RevisionPath" optional :limit, :int64, 3 end + add_message "gitaly.GetBlobsRequest.RevisionPath" do + optional :revision, :string, 1 + optional :path, :bytes, 2 + end add_message "gitaly.GetBlobsResponse" do optional :size, :int64, 1 optional :data, :bytes, 2 optional :oid, :string, 3 + optional :is_submodule, :bool, 4 + optional :mode, :int32, 5 + optional :revision, :string, 6 + optional :path, :bytes, 7 end add_message "gitaly.LFSPointer" do optional :size, :int64, 1 @@ -43,6 +51,7 @@ module Gitaly GetBlobRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("gitaly.GetBlobRequest").msgclass GetBlobResponse = Google::Protobuf::DescriptorPool.generated_pool.lookup("gitaly.GetBlobResponse").msgclass GetBlobsRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("gitaly.GetBlobsRequest").msgclass + GetBlobsRequest::RevisionPath = Google::Protobuf::DescriptorPool.generated_pool.lookup("gitaly.GetBlobsRequest.RevisionPath").msgclass GetBlobsResponse = Google::Protobuf::DescriptorPool.generated_pool.lookup("gitaly.GetBlobsResponse").msgclass LFSPointer = Google::Protobuf::DescriptorPool.generated_pool.lookup("gitaly.LFSPointer").msgclass GetLFSPointersRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("gitaly.GetLFSPointersRequest").msgclass diff --git a/ruby/lib/gitaly/blob_services_pb.rb b/ruby/lib/gitaly/blob_services_pb.rb index 58759b78..ed074398 100644 --- a/ruby/lib/gitaly/blob_services_pb.rb +++ b/ruby/lib/gitaly/blob_services_pb.rb @@ -18,10 +18,6 @@ module Gitaly # ID. We use a stream to return a chunked arbitrarily large binary # response rpc :GetBlob, GetBlobRequest, stream(GetBlobResponse) - # GetBlobsBySHA returns the contents of a blob objects referenced by their object - # ID. We use a stream to return a chunked arbitrarily large binary response. - # The blobs are sent in a continous stream, the caller is responsible for spliting - # them up into multiple blobs by their object IDs. rpc :GetBlobs, GetBlobsRequest, stream(GetBlobsResponse) rpc :GetLFSPointers, GetLFSPointersRequest, stream(GetLFSPointersResponse) end -- GitLab