generated from edgexfoundry-holding/template-repo
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathfactory.py
24 lines (18 loc) · 885 Bytes
/
factory.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
# Copyright (C) 2024 IOTech Ltd
# SPDX-License-Identifier: Apache-2.0
"""
This module provides the `new_registry_client` function, which creates a new registry client based
on the registry configuration provided.
"""
from ..registry.config import Config
from ..registry.keeper.client import KeeperClient, Client
def new_registry_client(registry_config: Config) -> Client:
"""
new_registry_client creates a new registry client based on the registry configuration provided.
"""
if not registry_config.host or registry_config.port == 0:
raise ValueError("unable to create client: registry host and/or port or serviceKey not set")
if registry_config.service_type == "keeper":
registry_client = KeeperClient(registry_config)
return registry_client
raise ValueError(f"Unknown registry type '{registry_config.service_type}' requested")