discovers a service. If timeout is specified, waits for at least minimum_providers service instance to be available.
        Note : we do not want to make the discovery block undefinitely since we never know for sure if a service is running or not
        TODO : improve with future...
        :param name: name of the service
        :param timeout: maximum number of seconds the discover can wait for a discovery matching requirements. if None, doesn't wait.
        :param minimum_providers the number of provider we need to reach before discover() returns if timeout enabled
        :return: a Service object, containing the list of providers. if the minimum number cannot be reached, still returns what is available.

def discover(name, timeout=None, minimum_providers=1):
        """
        discovers a service. If timeout is specified, waits for at least minimum_providers service instance to be available.
        Note : we do not want to make the discovery block undefinitely since we never know for sure if a service is running or not
        TODO : improve with future...
        :param name: name of the service
        :param timeout: maximum number of seconds the discover can wait for a discovery matching requirements. if None, doesn't wait.
        :param minimum_providers the number of provider we need to reach before discover() returns if timeout enabled
        :return: a Service object, containing the list of providers. if the minimum number cannot be reached, still returns what is available.
        """
        start = time.time()
        endtime = timeout if timeout else 0

        while True:
            timed_out = time.time() - start > endtime
            if name in services and isinstance(services[name], list):
                if len(services[name]) >= minimum_providers or timed_out:
                    providers = services[name]
                    if providers:
                        return Service(name, providers)
                    else:
                        return None

            if timed_out:
                break
            # else we keep looping after a short sleep ( to allow time to refresh services list )
            time.sleep(0.2)  # sleep
        return None