from ._Service import Service


class ServiceLocator(object):
    def __init__(self):
        self.regs = {}

    def register(
        self,
        service_type: str,
        service_name: str,
        address: str,
        port: int,
    ):
        self.regs[service_name] = Service(
            type=service_type,
            name=service_name,
            address=address,
            port=port,
        )

    def locate(self, service_name):
        return self.regs.get(service_name)
