Beispiel #1
0
 def internal_kv_exists(self, key: bytes) -> bool:
     req = gcs_service_pb2.InternalKVExistsRequest(key=key)
     reply = self._kv_stub.InternalKVExists(req)
     if reply.status.code == GcsCode.OK:
         return reply.exists
     else:
         raise RuntimeError(f"Failed to check existence of key {key} "
                            f"due to error {reply.status.message}")
Beispiel #2
0
 def internal_kv_exists(self, key: bytes, namespace: Optional[str]) -> bool:
     logger.debug(f"internal_kv_exists {key} {namespace}")
     key = _make_key(namespace, key)
     req = gcs_service_pb2.InternalKVExistsRequest(key=key)
     reply = self._kv_stub.InternalKVExists(req)
     if reply.status.code == GcsCode.OK:
         return reply.exists
     else:
         raise RuntimeError(f"Failed to check existence of key {key} "
                            f"due to error {reply.status.message}")
Beispiel #3
0
 async def internal_kv_exists(self,
                              key: bytes,
                              namespace: Optional[bytes],
                              timeout: Optional[float] = None) -> bool:
     logger.debug(f"internal_kv_exists {key!r} {namespace!r}")
     req = gcs_service_pb2.InternalKVExistsRequest(namespace=namespace,
                                                   key=key)
     reply = await self._kv_stub.InternalKVExists(req, timeout=timeout)
     if reply.status.code == GcsCode.OK:
         return reply.exists
     else:
         raise RuntimeError(f"Failed to check existence of key {key!r} "
                            f"due to error {reply.status.message}")