def prepareClient(client, username, password):
yield client.authenticate(username, password)
channel = yield client.channel(1)
yield channel.channel_open()
yield channel.exchange_declare(exchange=servicesExchange, type="direct")
yield channel.exchange_declare(exchange=responsesExchange, type="direct")
pfactory = TBinaryProtocol.TBinaryProtocolFactory()
# To trigger an unroutable message error (caught in the above
# gotTransportError errback), change the routing key (i.e.,
# calculatorKey) in the following to be something invalid, like
# calculatorKey + 'xxx'.
thriftClient = yield client.createThriftClient(responsesExchange,
servicesExchange, calculatorKey, tutorial.Calculator.Client,
iprot_factory=pfactory, oprot_factory=pfactory)
defer.returnValue(thriftClient)
评论列表
文章目录