Skip to content
Snippets Groups Projects
Commit 7d396fb3 authored by finnball's avatar finnball
Browse files

Instance classes can now add themselves to services.

parent 437e2ee0
No related branches found
No related tags found
No related merge requests found
......@@ -26,6 +26,9 @@ from ..referencestorage.storage import ReferenceCache
class ActionCache(ReferenceCache):
def register_instance_with_server(self, instance_name, server):
server.add_action_cache_instance(self, instance_name)
def get_action_result(self, action_digest):
key = self._get_key(action_digest)
return self.get_action_reference(key)
......
......@@ -36,6 +36,9 @@ class BotsInterface:
self._bot_sessions = {}
self._scheduler = scheduler
def register_instance_with_server(self, instance_name, server):
server.add_bots_interface(self, instance_name)
def create_bot_session(self, parent, bot_session):
""" Creates a new bot session. Server should assign a unique
name to the session. If a bot with the same bot id tries to
......
......@@ -31,6 +31,9 @@ class ContentAddressableStorageInstance:
def __init__(self, storage):
self._storage = storage
def register_instance_with_server(self, instance_name, server):
server.add_cas_instance(self, instance_name)
def find_missing_blobs(self, blob_digests):
storage = self._storage
return re_pb2.FindMissingBlobsResponse(
......@@ -60,6 +63,9 @@ class ByteStreamInstance:
def __init__(self, storage):
self._storage = storage
def register_instance_with_server(self, instance_name, server):
server.add_bytestream_instance(self, instance_name)
def read(self, path, read_offset, read_limit):
storage = self._storage
......
......@@ -45,6 +45,11 @@ class ExecutionController:
self._bots_interface = BotsInterface(scheduler)
self._operations_instance = OperationsInstance(scheduler)
def register_instance_with_server(self, instance_name, server):
server.add_execution_instance(self._execution_instance, instance_name)
server.add_bots_interface(self._bots_interface, instance_name)
server.add_operations_instance(self._operations_instance, instance_name)
def stream_operation_updates(self, message_queue, operation_name):
operation = message_queue.get()
while not operation.done:
......
......@@ -34,6 +34,9 @@ class ExecutionInstance:
self._storage = storage
self._scheduler = scheduler
def register_instance_with_server(self, instance_name, server):
server.add_execution_instance(self, instance_name)
def execute(self, action_digest, skip_cache_lookup, message_queue=None):
""" Sends a job for execution.
Queues an action and creates an Operation instance to be associated with
......
......@@ -30,6 +30,9 @@ class OperationsInstance:
self.logger = logging.getLogger(__name__)
self._scheduler = scheduler
def register_instance_with_server(self, instance_name, server):
server.add_operations_instance(self, instance_name)
def get_operation(self, name):
operation = self._scheduler.jobs.get(name)
......
......@@ -44,6 +44,9 @@ class ReferenceCache:
self._max_cached_refs = max_cached_refs
self._digest_map = collections.OrderedDict()
def register_instance_with_server(self, instance_name, server):
server.add_reference_storage_instance(self, instance_name)
@property
def allow_updates(self):
return self._allow_updates
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment