FAQ

Can I register an endpoint that accepts all requests?

The fallback endpoint is the endpoint called when an unrecognized request is received. By default, the fallback endpoint simply returns a BadRequestError to the caller. This behavior may be changed by registering an endpoint with TChannel.FALLBACK.

from tchannel import TChannel

server = TChannel(name='myservice')

@server.register(TChannel.FALLBACK)
def handler(request):
    # ...

This may be used to implement a TChannel server that can handle requests to all endpoints. Note that for the fallback endpoint, you have access to the raw bytes of the headers and the body. These must be serialized/deserialized manually.

Why do I keep getting a “Cannot serialize MyType into a ‘MyType’” error?

You are trying to mix code generated by Apache Thrift with the module generated by tchannel.thrift.load(). These are two separate ways of using Thrift with TChannel and the classes generated by either cannot be mixed and matched. You should be using only one of these approaches to interact with a specific service.