generated from edgexfoundry-holding/template-repo
-
Notifications
You must be signed in to change notification settings - Fork 3
/
interface.py
77 lines (59 loc) · 2.32 KB
/
interface.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# Copyright (C) 2024 IOTech Ltd
# SPDX-License-Identifier: Apache-2.0
"""
This module provides the `Client` abstract base class, which defines the interface for interactions
with the Keeper service.
Classes:
- Client: Abstract base class that defines methods for checking service availability,
registering, unregistering, and retrieving service endpoints.
"""
from abc import ABC, abstractmethod
from typing import List
from .keeper.client import ServiceEndpoint
class Client(ABC):
"""
Defines the interface for interactions with the Keeper service.
Methods:
is_alive() -> bool:
Checks if Keeper is up and running at the configured URL.
register() -> None:
Registers the current service with Keeper for discovery and health check.
unregister() -> None:
De-registers the current service from Keeper.
get_service_endpoint(service_key: str) -> ServiceEndpoint:
Retrieves the port, service ID, and host of a known endpoint from Keeper.
get_all_service_endpoints() -> List[ServiceEndpoint]:
Retrieves all registered endpoints from Keeper.
is_service_available(service_key: str) -> bool:
Checks with Keeper if the target service is registered and healthy.
"""
@abstractmethod
def is_alive(self) -> bool:
"""
Simply checks if Registry is up and running at the configured URL.
"""
@abstractmethod
def register(self) -> None:
"""
Registers the current service with Registry for discover and health check.
"""
@abstractmethod
def unregister(self) -> None:
"""
Un-registers the current service with Registry for discover and health check
"""
@abstractmethod
def get_service_endpoint(self, service_key: str) -> ServiceEndpoint:
"""
Gets the service endpoint information for the target ID from the Registry
"""
@abstractmethod
def get_all_service_endpoints(self) -> List[ServiceEndpoint]:
"""
Gets all the service endpoints information from the Registry
"""
@abstractmethod
def is_service_available(self, service_key: str) -> bool:
"""
Checks with the Registry if the target service is available, i.e. registered and healthy
"""