from __future__ import ( absolute_import, division, print_function, unicode_literals ) from os import path from tornado import gen import crossdock from crossdock import rand, transport as tr from yarpc import RPC, Request from yarpc.encoding.thrift import load, ThriftClient idl = path.join(path.dirname(crossdock.__file__), 'Echo.thrift') service = load(idl) @gen.coroutine def thrift(respw, server, transport, **kwargs): rpc = RPC( service='client', outbounds={ 'yarpc-test': tr.factory(server, transport), }, ) expected = rand.string(7) request = Request( body=service.Echo.echo(service.Ping(beep=expected)),
def service(): return thrift.load('tests/data/idls/ThriftTest.thrift')
# # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. from __future__ import ( absolute_import, division, print_function, unicode_literals ) from os import path import crossdock from yarpc import Response from yarpc.encoding import thrift idl = path.join(path.dirname(crossdock.__file__), 'Echo.thrift') service = thrift.load(idl) @thrift.procedure(service.Echo) def echo(request): pong = service.Pong(boop=request.body.ping.beep) return Response(body=pong, headers=request.headers)
def service(): return thrift.load(idl)