added some code to keep track of config services separately within core nodes, added function for starting config services during session instantiation

This commit is contained in:
Blake Harnden 2020-01-17 16:57:49 -08:00
parent dbc77d81f6
commit 191a9e9909
8 changed files with 87 additions and 26 deletions

View file

@ -5,12 +5,20 @@ from typing import List
from core import utils
from core.configservice.base import ConfigService
from core.errors import CoreError
from core.nodes.base import CoreNode
class ConfigServiceManager:
def __init__(self):
self.services = {}
def set_service(self, node: CoreNode, name: str) -> None:
service_class = self.services.get(name)
if service_class in node.config_services:
raise CoreError(f"node already has service {name}")
service = service_class(node)
node.config_services.add(service)
def add(self, service: ConfigService) -> None:
name = service.name
logging.debug("loading service: class(%s) name(%s)", service.__class__, name)
@ -34,6 +42,7 @@ class ConfigServiceManager:
def load(self, path: str) -> List[str]:
path = pathlib.Path(path)
subdirs = [x for x in path.iterdir() if x.is_dir()]
subdirs.append(path)
service_errors = []
for subdir in subdirs:
logging.info("loading config services from: %s", subdir)