Ejemplo n.º 1
0
    def _get_client_by_tier(self):
        """Get a client that uses ServiceRouter"""
        config = self.config
        serviceRouter = ServiceRouter()

        overrides = ConnConfigs()
        for key, val in six.iteritems(config.conn_configs):
            key = six.binary_type(key)
            val = six.binary_type(val)
            overrides[key] = val

        sr_options = ServiceOptions()
        for key, val in six.iteritems(config.service_options):
            key = six.binary_type(key)
            if not isinstance(val, list):
                raise TypeError(
                    "Service option %s expected list; got %s (%s)" %
                    (key, val, type(val)))
            val = [six.binary_type(elem) for elem in val]
            sr_options[key] = val

        service_name = config.tier

        # Obtain a normal client connection using SR2
        client = serviceRouter.getClient2(self.client_class, service_name,
                                          sr_options, overrides)

        if client is None:
            raise NameError('Failed to lookup host for tier %s' % service_name)

        return client
Ejemplo n.º 2
0
def getClient():
    options = ServiceOptions({"single_host": ("127.0.0.1", "9999")})

    overrides = ConnConfigs({
        # milliseconds
        "sock_sendtimeout": str(TIMEOUT),
        "sock_recvtimeout": str(TIMEOUT),
        "thrift_transport": "header",
        "thrift_security": "permitted",  # "required",
        "thrift_security_service_tier": "host",
    })

    return ServiceRouter().getClient2(
        ReverseService.Client,
        "keychain.service",  # TODO mhorowitz: make a tier
        options,
        overrides,
        False)
Ejemplo n.º 3
0
def getClient():
    options = ServiceOptions({"single_host": ("127.0.0.1", "9999")})

    overrides = ConnConfigs({
        # milliseconds
        "sock_sendtimeout": str(TIMEOUT),
        "sock_recvtimeout": str(TIMEOUT),
        "thrift_transport": "header",
        "thrift_security": "permitted",  # "required",
        "thrift_security_service_tier": "host",
    })

    return ServiceRouter().getClient2(
        ReverseService.Client,
        "",  # tier name; not needed since we're using single_host
        options,
        overrides,
        False)