Coverage for /builds/BuildGrid/buildgrid/buildgrid/server/controller.py: 100.00%

19 statements  

« prev     ^ index     » next       coverage.py v7.4.1, created at 2024-10-04 17:48 +0000

1# Copyright (C) 2018 Bloomberg LP 

2# 

3# Licensed under the Apache License, Version 2.0 (the "License"); 

4# you may not use this file except in compliance with the License. 

5# You may obtain a copy of the License at 

6# 

7# <http://www.apache.org/licenses/LICENSE-2.0> 

8# 

9# Unless required by applicable law or agreed to in writing, software 

10# distributed under the License is distributed on an "AS IS" BASIS, 

11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 

12# See the License for the specific language governing permissions and 

13# limitations under the License. 

14 

15 

16""" 

17Execution Controller 

18==================== 

19 

20An instance of the Execution controller. 

21 

22All this stuff you need to make the execution service work. 

23 

24Contains scheduler, execution instance, an interface to the bots 

25and an operations instance. 

26""" 

27from typing import Iterable, Optional 

28 

29from buildgrid.server.bots.instance import BotsInterface 

30from buildgrid.server.enums import ServiceName 

31from buildgrid.server.execution.instance import ExecutionInstance 

32from buildgrid.server.operations.instance import OperationsInstance 

33from buildgrid.server.scheduler import Scheduler 

34from buildgrid.server.settings import DEFAULT_MAX_LIST_OPERATION_PAGE_SIZE 

35 

36 

37class ExecutionController: 

38 def __init__( 

39 self, 

40 scheduler: Scheduler, 

41 *, 

42 operation_stream_keepalive_timeout: Optional[int] = None, 

43 services: Iterable[str] = ServiceName.default_services(), 

44 max_list_operations_page_size: int = DEFAULT_MAX_LIST_OPERATION_PAGE_SIZE, 

45 ) -> None: 

46 self.execution_instance: Optional[ExecutionInstance] = None 

47 if ServiceName.EXECUTION.value in services: 

48 self.execution_instance = ExecutionInstance(scheduler, operation_stream_keepalive_timeout) 

49 

50 self.operations_instance: Optional[OperationsInstance] = None 

51 if ServiceName.OPERATIONS.value in services: 

52 self.operations_instance = OperationsInstance(scheduler, max_list_operations_page_size) 

53 

54 self.bots_interface: Optional[BotsInterface] = None 

55 if ServiceName.BOTS.value in services: 

56 self.bots_interface = BotsInterface(scheduler)