Skip to content

Commit

Permalink
updated to print health response
Browse files Browse the repository at this point in the history
  • Loading branch information
naman108 committed Dec 23, 2023
1 parent d039830 commit ebf2fdc
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions DigitalPyHelloWorld/services/DPHelloWorld.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
""" this is the main class for the hello world digitalpy application"""
import os
import pathlib
from typing import TYPE_CHECKING
from digitalpy.core.main.DigitalPy import DigitalPy
from digitalpy.core.component_management.impl.component_registration_handler \
import ComponentRegistrationHandler

if TYPE_CHECKING:
from digitalpy.core.domain.domain.service_health import ServiceHealth


class DPHelloWorld(DigitalPy):
""" this is the main class for the hello world digitalpy application
Expand All @@ -27,9 +31,21 @@ def event_loop(self):
self.stop_service(service_id="hello_world.HelloService")
elif command == "3":
self.restart_service(service_id="hello_world.HelloService")
elif command == "4":
service_healths = self.get_all_service_health()
self.display_service_health(service_healths)
else:
print("Sorry, I don't understand that command.")

def display_service_health(self, service_healths: dict[str, 'ServiceHealth']):
"""display the service healths in a nice format
Args:
service_healths (list): the service healths to display
"""
for service, health in service_healths.items():
print(f"Service: {service}, Health: {health}")

def register_components(self):
# register hello world components
hello_world_components = ComponentRegistrationHandler.discover_components(
Expand Down

0 comments on commit ebf2fdc

Please sign in to comment.