refactor: remove service id altogether
Deploy bin / deploy (push) Successful in 2s
Deploy agebd python package / deploy (push) Successful in 4s

This commit is contained in:
Benjamin Labrecque
2026-07-08 16:47:42 +02:00
parent 3d921e69c1
commit debac0cf5e
34 changed files with 76 additions and 92 deletions
+5 -14
View File
@@ -11,7 +11,7 @@ REPO_ROOT = get_git_root(__file__)
CONFIG_DIR = REPO_ROOT / "config"
SERVICE_REGISTRY_FILENAME = CONFIG_DIR / "services_registry.yml"
MASTER_SERVICE_DIR = REPO_ROOT / "services" / "000-master" / "current"
MASTER_SERVICE_DIR = REPO_ROOT / "services" / "master" / "current"
MASTER_SERVICE_CONFIG_DIR = MASTER_SERVICE_DIR / "app" / "config"
MASTER_HLA_NAMES_FILENAME = MASTER_SERVICE_CONFIG_DIR / "hla_names.yml"
@@ -19,7 +19,6 @@ IOCS_OVERVIEW_FILENAME = REPO_ROOT / "docs" / "ioc" / "ioc_overview.md"
class Service(BaseModel):
id: int
name: str
ioc_port: int
status: ServiceStatus
@@ -34,12 +33,7 @@ class Service(BaseModel):
@property
def dir_name(self):
return f"{self.id_str}-{self.name_lower}"
@property
def id_str(self):
# TODO: max 999 services, enough?
return f"{self.id:03d}"
return f"{self.name_lower}"
def to_dict(self):
return {"name": self.name_lower, "ioc_port": self.ioc_port, "status": str(self.status)}
@@ -58,9 +52,8 @@ class Service(BaseModel):
class ServiceRegistry(BaseModel):
config_path: ClassVar[str] = str(SERVICE_REGISTRY_FILENAME)
next_available_id: int
next_available_ioc_port: int
services: dict[str, dict]
services: list[dict]
@classmethod
def read_from_config(cls) -> "ServiceRegistry":
@@ -71,17 +64,15 @@ class ServiceRegistry(BaseModel):
return registry
def get_services(self) -> list[Service]:
return [Service(id=int(svc_id), **svc_data) for svc_id, svc_data in self.services.items()]
return [Service(**svc_data) for svc_data in self.services]
def add_service(self, name: str) -> Service:
svc = Service(
id=self.next_available_id,
name=name,
ioc_port=self.next_available_ioc_port,
status=ServiceStatus.ACTIVE,
)
self.services.update({svc.id_str: svc.to_dict()})
self.next_available_id += 1
self.services.append(svc.to_dict())
self.next_available_ioc_port += 1
return svc
+3 -4
View File
@@ -23,7 +23,7 @@ REPO_ROOT = get_git_root(__file__)
SERVICE_TEMPLATES_DIR = REPO_ROOT / "templates" / "service"
SERVICE_DEST_DIR = REPO_ROOT / "services"
MASTER_SERVICE_DIR = REPO_ROOT / "services" / "000-master" / "current"
MASTER_SERVICE_DIR = REPO_ROOT / "services" / "master" / "current"
MASTER_IOC_SUBS_FILE = MASTER_SERVICE_DIR / "ioc" / "AGEBD-CPCL-MASTER_main.subs"
# TODO: lots of hardcoded paths. Create config object?
@@ -77,8 +77,8 @@ class ServiceCreator:
service_dir_rel_path=f"services/{service.dir_name}/current",
registry_file_rel_path="config/services_registry.yml",
# TODO: maybe assert/get correct master service dirname from registry
master_hla_names_rel_path="services/000-master/current/app/config/hla_names.yml",
master_ioc_subs_rel_path="services/000-master/current/ioc/AGEBD-CPCL-MASTER_main.subs",
master_hla_names_rel_path="services/master/current/app/config/hla_names.yml",
master_ioc_subs_rel_path="services/master/current/ioc/AGEBD-CPCL-MASTER_main.subs",
iocs_overview_rel_path="docs/ioc/ioc_overview.md",
commit_msg=f"feature: add new service {service.name_lower}",
)
@@ -103,7 +103,6 @@ class ServiceCreator:
src_path=str(SERVICE_TEMPLATES_DIR),
dst_path=str(SERVICE_DEST_DIR),
data={
"service_id": service.id_str,
"service_name_upper": service.name_upper,
"service_name_lower": service.name_lower,
"user": user,