Skip to content
Snippets Groups Projects
Commit 714c818f authored by finnball's avatar finnball Committed by finn
Browse files

Adding doc strings.

parent 39df7bcc
No related branches found
No related tags found
Loading
...@@ -13,13 +13,6 @@ ...@@ -13,13 +13,6 @@
# limitations under the License. # limitations under the License.
"""
BuildGridServer
==============
Creates a BuildGrid server, binding all the requisite service instances together.
"""
import logging import logging
import os import os
from concurrent import futures from concurrent import futures
...@@ -35,8 +28,18 @@ from .referencestorage.service import ReferenceStorageService ...@@ -35,8 +28,18 @@ from .referencestorage.service import ReferenceStorageService
class BuildGridServer: class BuildGridServer:
"""Creates a BuildGrid server.
The :class:`BuildGridServer` class binds together all the
requisite services.
"""
def __init__(self, max_workers=None): def __init__(self, max_workers=None):
"""Initializes a new :class:`BuildGridServer` instance.
Args:
max_workers (int, optional): A pool of max worker threads.
"""
self.logger = logging.getLogger(__name__) self.logger = logging.getLogger(__name__)
...@@ -57,12 +60,25 @@ class BuildGridServer: ...@@ -57,12 +60,25 @@ class BuildGridServer:
self._bytestream_service = None self._bytestream_service = None
def start(self): def start(self):
"""Starts the server.
"""
self._server.start() self._server.start()
def stop(self, grace=0): def stop(self, grace=0):
"""Stops the server.
"""
self._server.stop(grace) self._server.stop(grace)
def add_port(self, address, credentials): def add_port(self, address, credentials):
"""Adds a port to the server.
Must be called before the server starts. If a credentials object exists,
it will make a secure port.
Args:
address (str): The address with port number.
credentials (:obj:`grpc.ChannelCredentials`): Credentials object.
"""
if credentials is not None: if credentials is not None:
self.logger.info("Adding secure connection on: [{}]".format(address)) self.logger.info("Adding secure connection on: [{}]".format(address))
self._server.add_secure_port(address, credentials) self._server.add_secure_port(address, credentials)
...@@ -72,42 +88,98 @@ class BuildGridServer: ...@@ -72,42 +88,98 @@ class BuildGridServer:
self._server.add_insecure_port(address) self._server.add_insecure_port(address)
def add_execution_instance(self, instance, instance_name): def add_execution_instance(self, instance, instance_name):
"""Adds an :obj:`ExecutionInstance` to the service.
If no service exists, it creates one.
Args:
instance (:obj:`ExecutionInstance`): Instance to add.
instance_name (str): Instance name.
"""
if self._execution_service is None: if self._execution_service is None:
self._execution_service = ExecutionService(self._server) self._execution_service = ExecutionService(self._server)
self._execution_service.add_instance(instance_name, instance) self._execution_service.add_instance(instance_name, instance)
def add_bots_interface(self, instance, instance_name): def add_bots_interface(self, instance, instance_name):
"""Adds a :obj:`BotsInterface` to the service.
If no service exists, it creates one.
Args:
instance (:obj:`BotsInterface`): Instance to add.
instance_name (str): Instance name.
"""
if self._bots_service is None: if self._bots_service is None:
self._bots_service = BotsService(self._server) self._bots_service = BotsService(self._server)
self._bots_service.add_instance(instance_name, instance) self._bots_service.add_instance(instance_name, instance)
def add_operations_instance(self, instance, instance_name): def add_operations_instance(self, instance, instance_name):
"""Adds an :obj:`OperationsInstance` to the service.
If no service exists, it creates one.
Args:
instance (:obj:`OperationsInstance`): Instance to add.
instance_name (str): Instance name.
"""
if self._operations_service is None: if self._operations_service is None:
self._operations_service = OperationsService(self._server) self._operations_service = OperationsService(self._server)
self._operations_service.add_instance(instance_name, instance) self._operations_service.add_instance(instance_name, instance)
def add_reference_storage_instance(self, instance, instance_name): def add_reference_storage_instance(self, instance, instance_name):
"""Adds a :obj:`ReferenceCache` to the service.
If no service exists, it creates one.
Args:
instance (:obj:`ReferenceCache`): Instance to add.
instance_name (str): Instance name.
"""
if self._reference_storage_service is None: if self._reference_storage_service is None:
self._reference_storage_service = ReferenceStorageService(self._server) self._reference_storage_service = ReferenceStorageService(self._server)
self._reference_storage_service.add_instance(instance_name, instance) self._reference_storage_service.add_instance(instance_name, instance)
def add_action_cache_instance(self, instance, instance_name): def add_action_cache_instance(self, instance, instance_name):
"""Adds a :obj:`ReferenceCache` to the service.
If no service exists, it creates one.
Args:
instance (:obj:`ReferenceCache`): Instance to add.
instance_name (str): Instance name.
"""
if self._action_cache_service is None: if self._action_cache_service is None:
self._action_cache_service = ActionCacheService(self._server) self._action_cache_service = ActionCacheService(self._server)
self._action_cache_service.add_instance(instance_name, instance) self._action_cache_service.add_instance(instance_name, instance)
def add_cas_instance(self, instance, instance_name): def add_cas_instance(self, instance, instance_name):
"""Stores a :obj:`ContentAddressableStorageInstance` to the service.
If no service exists, it creates one.
Args:
instance (:obj:`ReferenceCache`): Instance to add.
instance_name (str): Instance name.
"""
if self._cas_service is None: if self._cas_service is None:
self._cas_service = ContentAddressableStorageService(self._server) self._cas_service = ContentAddressableStorageService(self._server)
self._cas_service.add_instance(instance_name, instance) self._cas_service.add_instance(instance_name, instance)
def add_bytestream_instance(self, instance, instance_name): def add_bytestream_instance(self, instance, instance_name):
"""Stores a :obj:`ByteStreamInstance` to the service.
If no service exists, it creates one.
Args:
instance (:obj:`ByteStreamInstance`): Instance to add.
instance_name (str): Instance name.
"""
if self._bytestream_service is None: if self._bytestream_service is None:
self._bytestream_service = ByteStreamService(self._server) self._bytestream_service = ByteStreamService(self._server)
......
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