Coverage for /builds/BuildGrid/buildgrid/buildgrid/server/types.py: 77.78%

18 statements  

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

1# Copyright (C) 2021 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 

16from typing import Any, Dict, Protocol, Tuple, Type, TypeVar, Union 

17 

18GrpcTrailingMetadata = Tuple[Tuple[str, Union[str, bytes]], ...] 

19LogStreamConnectionConfig = Dict[str, Union[str, Dict[str, str]]] 

20 

21 

22class OnServerStartCallback(Protocol): 

23 def __call__(self) -> Any: ... 

24 

25 

26class PortAssignedCallback(Protocol): 

27 def __call__(self, port_map: Dict[Any, int]) -> Any: ... 

28 

29 

30Cls = TypeVar("Cls") 

31 

32 

33class MessageType(Protocol): 

34 # Acts like a protobuf message. Add methods as needed. 

35 

36 @classmethod 

37 def FromString(cls: Type[Cls], s: bytes) -> Cls: 

38 pass 

39 

40 def SerializeToString(self: Any, *, deterministic: bool = ...) -> bytes: 

41 pass 

42 

43 def ParseFromString(self, serialized: bytes) -> int: 

44 pass 

45 

46 def Clear(self) -> None: 

47 pass