baseplate.context.thrift
¶
-
class
baseplate.context.thrift.
ThriftContextFactory
(pool, client_cls)¶ Thrift client pool context factory.
This factory will attach a proxy object with the same interface as your thrift client to an attribute on the context object. When a thrift method is called on this proxy object, it will check out a connection from the connection pool and execute the RPC, automatically recording diagnostic information.
Parameters: - pool (baseplate.thrift_pool.ThriftConnectionPool) – The connection pool.
- client_cls – The class object of a Thrift-generated client class,
e.g.
YourService.Client
.
The proxy object has a
retrying
method which takes the same parameters asRetryPolicy.new
and acts as a context manager. The context manager returns another proxy object where Thrift service method calls will be automatically retried with the specified retry policy when transient errors occur:with context.my_service.retrying(attempts=3) as svc: svc.some_method()