Skip to content
GitLab
Next
Menu
Why GitLab
Pricing
Contact Sales
Explore
Why GitLab
Pricing
Contact Sales
Explore
Sign in
Get free trial
Primary navigation
Search or go to…
Project
buildgrid
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Privacy statement
Keyboard shortcuts
?
What's new
6
Snippets
Groups
Projects
Show more breadcrumbs
BuildGrid
buildgrid
Commits
714c818f
Commit
714c818f
authored
6 years ago
by
finnball
Committed by
finn
6 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Adding doc strings.
parent
39df7bcc
No related branches found
No related tags found
Loading
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
buildgrid/server/instance.py
+79
-7
79 additions, 7 deletions
buildgrid/server/instance.py
with
79 additions
and
7 deletions
buildgrid/server/instance.py
+
79
−
7
View file @
714c818f
...
@@ -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
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment