diff options
author | Jürg Billeter <j@bitron.ch> | 2018-03-15 10:13:23 +0100 |
---|---|---|
committer | Jürg Billeter <j@bitron.ch> | 2018-07-17 07:56:40 +0200 |
commit | 8a0fe2739a78484d23772eddcb56198fe5b6552b (patch) | |
tree | ce8ea04761088a8fe25bb66ffbb7bd27f23326d4 | |
parent | bed6c800bd3c97624d76b4de60c1bb98bb08d07f (diff) | |
download | buildstream-8a0fe2739a78484d23772eddcb56198fe5b6552b.tar.gz |
Add proto for BuildStream reference storage service
-rw-r--r-- | buildstream/_protos/buildstream/__init__.py | 0 | ||||
-rw-r--r-- | buildstream/_protos/buildstream/v2/__init__.py | 0 | ||||
-rw-r--r-- | buildstream/_protos/buildstream/v2/buildstream.proto | 95 | ||||
-rw-r--r-- | buildstream/_protos/buildstream/v2/buildstream_pb2.py | 325 | ||||
-rw-r--r-- | buildstream/_protos/buildstream/v2/buildstream_pb2_grpc.py | 89 |
5 files changed, 509 insertions, 0 deletions
diff --git a/buildstream/_protos/buildstream/__init__.py b/buildstream/_protos/buildstream/__init__.py new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/buildstream/_protos/buildstream/__init__.py diff --git a/buildstream/_protos/buildstream/v2/__init__.py b/buildstream/_protos/buildstream/v2/__init__.py new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/buildstream/_protos/buildstream/v2/__init__.py diff --git a/buildstream/_protos/buildstream/v2/buildstream.proto b/buildstream/_protos/buildstream/v2/buildstream.proto new file mode 100644 index 000000000..f283d6f3f --- /dev/null +++ b/buildstream/_protos/buildstream/v2/buildstream.proto @@ -0,0 +1,95 @@ +// Copyright 2018 Codethink Limited +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package buildstream.v2; + +import "build/bazel/remote/execution/v2/remote_execution.proto"; +import "google/api/annotations.proto"; + +service ReferenceStorage { + // Retrieve a CAS [Directory][build.bazel.remote.execution.v2.Directory] + // digest by name. + // + // Errors: + // * `NOT_FOUND`: The requested reference is not in the cache. + rpc GetReference(GetReferenceRequest) returns (GetReferenceResponse) { + option (google.api.http) = { get: "/v2/{instance_name=**}/buildstream/refs/{key}" }; + } + + // Associate a name with a CAS [Directory][build.bazel.remote.execution.v2.Directory] + // digest. + // + // Errors: + // * `RESOURCE_EXHAUSTED`: There is insufficient storage space to add the + // entry to the cache. + rpc UpdateReference(UpdateReferenceRequest) returns (UpdateReferenceResponse) { + option (google.api.http) = { put: "/v2/{instance_name=**}/buildstream/refs/{key}" body: "digest" }; + } + + rpc Status(StatusRequest) returns (StatusResponse) { + option (google.api.http) = { put: "/v2/{instance_name=**}/buildstream/refs:status" }; + } +} + +message GetReferenceRequest { + // The instance of the execution system to operate against. A server may + // support multiple instances of the execution system (with their own workers, + // storage, caches, etc.). The server MAY require use of this field to select + // between them in an implementation-defined fashion, otherwise it can be + // omitted. + string instance_name = 1; + + // The name of the reference. + string key = 2; +} + +message GetReferenceResponse { + // The digest of the CAS [Directory][build.bazel.remote.execution.v2.Directory]. + build.bazel.remote.execution.v2.Digest digest = 1; +} + +message UpdateReferenceRequest { + // The instance of the execution system to operate against. A server may + // support multiple instances of the execution system (with their own workers, + // storage, caches, etc.). The server MAY require use of this field to select + // between them in an implementation-defined fashion, otherwise it can be + // omitted. + string instance_name = 1; + + // The name of the reference. + repeated string keys = 2; + + // The digest of the CAS [Directory][build.bazel.remote.execution.v2.Directory] + // to store in the cache. + build.bazel.remote.execution.v2.Digest digest = 3; +} + +message UpdateReferenceResponse { +} + +message StatusRequest { + // The instance of the execution system to operate against. A server may + // support multiple instances of the execution system (with their own workers, + // storage, caches, etc.). The server MAY require use of this field to select + // between them in an implementation-defined fashion, otherwise it can be + // omitted. + string instance_name = 1; +} + +message StatusResponse { + // Whether reference updates are allowed for the connected client. + bool allow_updates = 1; +} diff --git a/buildstream/_protos/buildstream/v2/buildstream_pb2.py b/buildstream/_protos/buildstream/v2/buildstream_pb2.py new file mode 100644 index 000000000..57fdae49d --- /dev/null +++ b/buildstream/_protos/buildstream/v2/buildstream_pb2.py @@ -0,0 +1,325 @@ +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: buildstream/v2/buildstream.proto + +import sys +_b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1')) +from google.protobuf import descriptor as _descriptor +from google.protobuf import message as _message +from google.protobuf import reflection as _reflection +from google.protobuf import symbol_database as _symbol_database +from google.protobuf import descriptor_pb2 +# @@protoc_insertion_point(imports) + +_sym_db = _symbol_database.Default() + + +from buildstream._protos.build.bazel.remote.execution.v2 import remote_execution_pb2 as build_dot_bazel_dot_remote_dot_execution_dot_v2_dot_remote__execution__pb2 +from buildstream._protos.google.api import annotations_pb2 as google_dot_api_dot_annotations__pb2 + + +DESCRIPTOR = _descriptor.FileDescriptor( + name='buildstream/v2/buildstream.proto', + package='buildstream.v2', + syntax='proto3', + serialized_pb=_b('\n buildstream/v2/buildstream.proto\x12\x0e\x62uildstream.v2\x1a\x36\x62uild/bazel/remote/execution/v2/remote_execution.proto\x1a\x1cgoogle/api/annotations.proto\"9\n\x13GetReferenceRequest\x12\x15\n\rinstance_name\x18\x01 \x01(\t\x12\x0b\n\x03key\x18\x02 \x01(\t\"O\n\x14GetReferenceResponse\x12\x37\n\x06\x64igest\x18\x01 \x01(\x0b\x32\'.build.bazel.remote.execution.v2.Digest\"v\n\x16UpdateReferenceRequest\x12\x15\n\rinstance_name\x18\x01 \x01(\t\x12\x0c\n\x04keys\x18\x02 \x03(\t\x12\x37\n\x06\x64igest\x18\x03 \x01(\x0b\x32\'.build.bazel.remote.execution.v2.Digest\"\x19\n\x17UpdateReferenceResponse\"&\n\rStatusRequest\x12\x15\n\rinstance_name\x18\x01 \x01(\t\"\'\n\x0eStatusResponse\x12\x15\n\rallow_updates\x18\x01 \x01(\x08\x32\xca\x03\n\x10ReferenceStorage\x12\x90\x01\n\x0cGetReference\x12#.buildstream.v2.GetReferenceRequest\x1a$.buildstream.v2.GetReferenceResponse\"5\x82\xd3\xe4\x93\x02/\x12-/v2/{instance_name=**}/buildstream/refs/{key}\x12\xa1\x01\n\x0fUpdateReference\x12&.buildstream.v2.UpdateReferenceRequest\x1a\'.buildstream.v2.UpdateReferenceResponse\"=\x82\xd3\xe4\x93\x02\x37\x1a-/v2/{instance_name=**}/buildstream/refs/{key}:\x06\x64igest\x12\x7f\n\x06Status\x12\x1d.buildstream.v2.StatusRequest\x1a\x1e.buildstream.v2.StatusResponse\"6\x82\xd3\xe4\x93\x02\x30\x1a./v2/{instance_name=**}/buildstream/refs:statusb\x06proto3') + , + dependencies=[build_dot_bazel_dot_remote_dot_execution_dot_v2_dot_remote__execution__pb2.DESCRIPTOR,google_dot_api_dot_annotations__pb2.DESCRIPTOR,]) + + + + +_GETREFERENCEREQUEST = _descriptor.Descriptor( + name='GetReferenceRequest', + full_name='buildstream.v2.GetReferenceRequest', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='instance_name', full_name='buildstream.v2.GetReferenceRequest.instance_name', index=0, + number=1, type=9, cpp_type=9, label=1, + has_default_value=False, default_value=_b("").decode('utf-8'), + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='key', full_name='buildstream.v2.GetReferenceRequest.key', index=1, + number=2, type=9, cpp_type=9, label=1, + has_default_value=False, default_value=_b("").decode('utf-8'), + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None, file=DESCRIPTOR), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=138, + serialized_end=195, +) + + +_GETREFERENCERESPONSE = _descriptor.Descriptor( + name='GetReferenceResponse', + full_name='buildstream.v2.GetReferenceResponse', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='digest', full_name='buildstream.v2.GetReferenceResponse.digest', index=0, + number=1, type=11, cpp_type=10, label=1, + has_default_value=False, default_value=None, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None, file=DESCRIPTOR), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=197, + serialized_end=276, +) + + +_UPDATEREFERENCEREQUEST = _descriptor.Descriptor( + name='UpdateReferenceRequest', + full_name='buildstream.v2.UpdateReferenceRequest', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='instance_name', full_name='buildstream.v2.UpdateReferenceRequest.instance_name', index=0, + number=1, type=9, cpp_type=9, label=1, + has_default_value=False, default_value=_b("").decode('utf-8'), + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='keys', full_name='buildstream.v2.UpdateReferenceRequest.keys', index=1, + number=2, type=9, cpp_type=9, label=3, + has_default_value=False, default_value=[], + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='digest', full_name='buildstream.v2.UpdateReferenceRequest.digest', index=2, + number=3, type=11, cpp_type=10, label=1, + has_default_value=False, default_value=None, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None, file=DESCRIPTOR), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=278, + serialized_end=396, +) + + +_UPDATEREFERENCERESPONSE = _descriptor.Descriptor( + name='UpdateReferenceResponse', + full_name='buildstream.v2.UpdateReferenceResponse', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=398, + serialized_end=423, +) + + +_STATUSREQUEST = _descriptor.Descriptor( + name='StatusRequest', + full_name='buildstream.v2.StatusRequest', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='instance_name', full_name='buildstream.v2.StatusRequest.instance_name', index=0, + number=1, type=9, cpp_type=9, label=1, + has_default_value=False, default_value=_b("").decode('utf-8'), + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None, file=DESCRIPTOR), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=425, + serialized_end=463, +) + + +_STATUSRESPONSE = _descriptor.Descriptor( + name='StatusResponse', + full_name='buildstream.v2.StatusResponse', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='allow_updates', full_name='buildstream.v2.StatusResponse.allow_updates', index=0, + number=1, type=8, cpp_type=7, label=1, + has_default_value=False, default_value=False, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None, file=DESCRIPTOR), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=465, + serialized_end=504, +) + +_GETREFERENCERESPONSE.fields_by_name['digest'].message_type = build_dot_bazel_dot_remote_dot_execution_dot_v2_dot_remote__execution__pb2._DIGEST +_UPDATEREFERENCEREQUEST.fields_by_name['digest'].message_type = build_dot_bazel_dot_remote_dot_execution_dot_v2_dot_remote__execution__pb2._DIGEST +DESCRIPTOR.message_types_by_name['GetReferenceRequest'] = _GETREFERENCEREQUEST +DESCRIPTOR.message_types_by_name['GetReferenceResponse'] = _GETREFERENCERESPONSE +DESCRIPTOR.message_types_by_name['UpdateReferenceRequest'] = _UPDATEREFERENCEREQUEST +DESCRIPTOR.message_types_by_name['UpdateReferenceResponse'] = _UPDATEREFERENCERESPONSE +DESCRIPTOR.message_types_by_name['StatusRequest'] = _STATUSREQUEST +DESCRIPTOR.message_types_by_name['StatusResponse'] = _STATUSRESPONSE +_sym_db.RegisterFileDescriptor(DESCRIPTOR) + +GetReferenceRequest = _reflection.GeneratedProtocolMessageType('GetReferenceRequest', (_message.Message,), dict( + DESCRIPTOR = _GETREFERENCEREQUEST, + __module__ = 'buildstream.v2.buildstream_pb2' + # @@protoc_insertion_point(class_scope:buildstream.v2.GetReferenceRequest) + )) +_sym_db.RegisterMessage(GetReferenceRequest) + +GetReferenceResponse = _reflection.GeneratedProtocolMessageType('GetReferenceResponse', (_message.Message,), dict( + DESCRIPTOR = _GETREFERENCERESPONSE, + __module__ = 'buildstream.v2.buildstream_pb2' + # @@protoc_insertion_point(class_scope:buildstream.v2.GetReferenceResponse) + )) +_sym_db.RegisterMessage(GetReferenceResponse) + +UpdateReferenceRequest = _reflection.GeneratedProtocolMessageType('UpdateReferenceRequest', (_message.Message,), dict( + DESCRIPTOR = _UPDATEREFERENCEREQUEST, + __module__ = 'buildstream.v2.buildstream_pb2' + # @@protoc_insertion_point(class_scope:buildstream.v2.UpdateReferenceRequest) + )) +_sym_db.RegisterMessage(UpdateReferenceRequest) + +UpdateReferenceResponse = _reflection.GeneratedProtocolMessageType('UpdateReferenceResponse', (_message.Message,), dict( + DESCRIPTOR = _UPDATEREFERENCERESPONSE, + __module__ = 'buildstream.v2.buildstream_pb2' + # @@protoc_insertion_point(class_scope:buildstream.v2.UpdateReferenceResponse) + )) +_sym_db.RegisterMessage(UpdateReferenceResponse) + +StatusRequest = _reflection.GeneratedProtocolMessageType('StatusRequest', (_message.Message,), dict( + DESCRIPTOR = _STATUSREQUEST, + __module__ = 'buildstream.v2.buildstream_pb2' + # @@protoc_insertion_point(class_scope:buildstream.v2.StatusRequest) + )) +_sym_db.RegisterMessage(StatusRequest) + +StatusResponse = _reflection.GeneratedProtocolMessageType('StatusResponse', (_message.Message,), dict( + DESCRIPTOR = _STATUSRESPONSE, + __module__ = 'buildstream.v2.buildstream_pb2' + # @@protoc_insertion_point(class_scope:buildstream.v2.StatusResponse) + )) +_sym_db.RegisterMessage(StatusResponse) + + + +_REFERENCESTORAGE = _descriptor.ServiceDescriptor( + name='ReferenceStorage', + full_name='buildstream.v2.ReferenceStorage', + file=DESCRIPTOR, + index=0, + options=None, + serialized_start=507, + serialized_end=965, + methods=[ + _descriptor.MethodDescriptor( + name='GetReference', + full_name='buildstream.v2.ReferenceStorage.GetReference', + index=0, + containing_service=None, + input_type=_GETREFERENCEREQUEST, + output_type=_GETREFERENCERESPONSE, + options=_descriptor._ParseOptions(descriptor_pb2.MethodOptions(), _b('\202\323\344\223\002/\022-/v2/{instance_name=**}/buildstream/refs/{key}')), + ), + _descriptor.MethodDescriptor( + name='UpdateReference', + full_name='buildstream.v2.ReferenceStorage.UpdateReference', + index=1, + containing_service=None, + input_type=_UPDATEREFERENCEREQUEST, + output_type=_UPDATEREFERENCERESPONSE, + options=_descriptor._ParseOptions(descriptor_pb2.MethodOptions(), _b('\202\323\344\223\0027\032-/v2/{instance_name=**}/buildstream/refs/{key}:\006digest')), + ), + _descriptor.MethodDescriptor( + name='Status', + full_name='buildstream.v2.ReferenceStorage.Status', + index=2, + containing_service=None, + input_type=_STATUSREQUEST, + output_type=_STATUSRESPONSE, + options=_descriptor._ParseOptions(descriptor_pb2.MethodOptions(), _b('\202\323\344\223\0020\032./v2/{instance_name=**}/buildstream/refs:status')), + ), +]) +_sym_db.RegisterServiceDescriptor(_REFERENCESTORAGE) + +DESCRIPTOR.services_by_name['ReferenceStorage'] = _REFERENCESTORAGE + +# @@protoc_insertion_point(module_scope) diff --git a/buildstream/_protos/buildstream/v2/buildstream_pb2_grpc.py b/buildstream/_protos/buildstream/v2/buildstream_pb2_grpc.py new file mode 100644 index 000000000..b3e653493 --- /dev/null +++ b/buildstream/_protos/buildstream/v2/buildstream_pb2_grpc.py @@ -0,0 +1,89 @@ +# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT! +import grpc + +from buildstream._protos.buildstream.v2 import buildstream_pb2 as buildstream_dot_v2_dot_buildstream__pb2 + + +class ReferenceStorageStub(object): + # missing associated documentation comment in .proto file + pass + + def __init__(self, channel): + """Constructor. + + Args: + channel: A grpc.Channel. + """ + self.GetReference = channel.unary_unary( + '/buildstream.v2.ReferenceStorage/GetReference', + request_serializer=buildstream_dot_v2_dot_buildstream__pb2.GetReferenceRequest.SerializeToString, + response_deserializer=buildstream_dot_v2_dot_buildstream__pb2.GetReferenceResponse.FromString, + ) + self.UpdateReference = channel.unary_unary( + '/buildstream.v2.ReferenceStorage/UpdateReference', + request_serializer=buildstream_dot_v2_dot_buildstream__pb2.UpdateReferenceRequest.SerializeToString, + response_deserializer=buildstream_dot_v2_dot_buildstream__pb2.UpdateReferenceResponse.FromString, + ) + self.Status = channel.unary_unary( + '/buildstream.v2.ReferenceStorage/Status', + request_serializer=buildstream_dot_v2_dot_buildstream__pb2.StatusRequest.SerializeToString, + response_deserializer=buildstream_dot_v2_dot_buildstream__pb2.StatusResponse.FromString, + ) + + +class ReferenceStorageServicer(object): + # missing associated documentation comment in .proto file + pass + + def GetReference(self, request, context): + """Retrieve a CAS [Directory][build.bazel.remote.execution.v2.Directory] + digest by name. + + Errors: + * `NOT_FOUND`: The requested reference is not in the cache. + """ + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details('Method not implemented!') + raise NotImplementedError('Method not implemented!') + + def UpdateReference(self, request, context): + """Associate a name with a CAS [Directory][build.bazel.remote.execution.v2.Directory] + digest. + + Errors: + * `RESOURCE_EXHAUSTED`: There is insufficient storage space to add the + entry to the cache. + """ + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details('Method not implemented!') + raise NotImplementedError('Method not implemented!') + + def Status(self, request, context): + # missing associated documentation comment in .proto file + pass + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details('Method not implemented!') + raise NotImplementedError('Method not implemented!') + + +def add_ReferenceStorageServicer_to_server(servicer, server): + rpc_method_handlers = { + 'GetReference': grpc.unary_unary_rpc_method_handler( + servicer.GetReference, + request_deserializer=buildstream_dot_v2_dot_buildstream__pb2.GetReferenceRequest.FromString, + response_serializer=buildstream_dot_v2_dot_buildstream__pb2.GetReferenceResponse.SerializeToString, + ), + 'UpdateReference': grpc.unary_unary_rpc_method_handler( + servicer.UpdateReference, + request_deserializer=buildstream_dot_v2_dot_buildstream__pb2.UpdateReferenceRequest.FromString, + response_serializer=buildstream_dot_v2_dot_buildstream__pb2.UpdateReferenceResponse.SerializeToString, + ), + 'Status': grpc.unary_unary_rpc_method_handler( + servicer.Status, + request_deserializer=buildstream_dot_v2_dot_buildstream__pb2.StatusRequest.FromString, + response_serializer=buildstream_dot_v2_dot_buildstream__pb2.StatusResponse.SerializeToString, + ), + } + generic_handler = grpc.method_handlers_generic_handler( + 'buildstream.v2.ReferenceStorage', rpc_method_handlers) + server.add_generic_rpc_handlers((generic_handler,)) |