baseplate.frameworks.thrift
¶
Thrift is a cross-language framework for cross-service communication. Developers write a language-independent definition of a service’s API (the “IDL”) and Thrift’s code generator makes server and client libraries for that API.
This module provides a wrapper for a TProcessor
which integrates
Baseplate’s facilities into the Thrift request lifecycle.
An abbreviated example of it in use:
logger = logging.getLogger(__name__)
def make_processor(app_config):
baseplate = Baseplate(app_config)
handler = MyHandler()
processor = my_thrift.MyService.Processor(handler)
return baseplateify_processor(processor, logger, baseplate)
-
baseplate.frameworks.thrift.
baseplateify_processor
(processor, logger, baseplate, edge_context_factory=None, convert_to_baseplate_error=False)[source]¶ Wrap a Thrift Processor with Baseplate’s span lifecycle.
- Parameters
processor (
TProcessor
) – The service’s processor to wrap.logger (
Logger
) – The logger to use for error and debug logging.baseplate (
Baseplate
) – The baseplate instance for your application.edge_context_factory (
Optional
[EdgeContextFactory
,None
]) – A configured factory for handling edge request context.convert_to_baseplate_error (
bool
) –If True, the server will automatically convert unhandled exceptions to:
- baseplate.Error(
code=ErrorCode.INTERNAL_SERVER_ERROR, message=”Internal server error”,
)
- Return type
TProcessor