diff options
author | Jürg Billeter <j@bitron.ch> | 2018-09-10 11:25:39 +0200 |
---|---|---|
committer | Jürg Billeter <j@bitron.ch> | 2018-09-10 17:43:25 +0200 |
commit | 47f3064a1101653eb878c0fcf29a68b6fc5eadd5 (patch) | |
tree | 7034d5b5f44fe4553ffada9e9d4dd1389e875ccd | |
parent | e0bb71b24c6e40a5dd2ee935352a301ae2113895 (diff) | |
download | buildstream-47f3064a1101653eb878c0fcf29a68b6fc5eadd5.tar.gz |
_artifactcache/casserver.py: Implement Capabilities service
-rw-r--r-- | buildstream/_artifactcache/casserver.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/buildstream/_artifactcache/casserver.py b/buildstream/_artifactcache/casserver.py index 0af65729b..f89421d88 100644 --- a/buildstream/_artifactcache/casserver.py +++ b/buildstream/_artifactcache/casserver.py @@ -38,6 +38,10 @@ from .._context import Context from .cascache import CASCache +# The default limit for gRPC messages is 4 MiB +_MAX_BATCH_TOTAL_SIZE_BYTES = 4 * 1024 * 1024 + + # Trying to push an artifact that is too large class ArtifactTooLargeException(Exception): pass @@ -67,6 +71,9 @@ def create_server(repo, *, enable_push): remote_execution_pb2_grpc.add_ContentAddressableStorageServicer_to_server( _ContentAddressableStorageServicer(artifactcache), server) + remote_execution_pb2_grpc.add_CapabilitiesServicer_to_server( + _CapabilitiesServicer(), server) + buildstream_pb2_grpc.add_ReferenceStorageServicer_to_server( _ReferenceStorageServicer(artifactcache, enable_push=enable_push), server) @@ -230,6 +237,23 @@ class _ContentAddressableStorageServicer(remote_execution_pb2_grpc.ContentAddres return response +class _CapabilitiesServicer(remote_execution_pb2_grpc.CapabilitiesServicer): + def GetCapabilities(self, request, context): + response = remote_execution_pb2.ServerCapabilities() + + cache_capabilities = response.cache_capabilities + cache_capabilities.digest_function.append(remote_execution_pb2.SHA256) + cache_capabilities.action_cache_update_capabilities.update_enabled = False + cache_capabilities.max_batch_total_size_bytes = _MAX_BATCH_TOTAL_SIZE_BYTES + cache_capabilities.symlink_absolute_path_strategy = remote_execution_pb2.CacheCapabilities.ALLOWED + + response.deprecated_api_version.major = 2 + response.low_api_version.major = 2 + response.high_api_version.major = 2 + + return response + + class _ReferenceStorageServicer(buildstream_pb2_grpc.ReferenceStorageServicer): def __init__(self, cas, *, enable_push): super().__init__() |