com.twitter.finagle.thrift.exp.partitioning
A request merger defines the merger function needed to define a Finagle partitioning service for Thrift services.
A request merger defines the merger function needed to define a Finagle partitioning service for Thrift services.
This is used for HashingPartitioningStrategy, which applies a consistent hashing partitioning strategy under the hood. Note that more than one request may fall in the same HashNode, even though they're assigned with different hashing keys. It merges a collection of requests to a final request which matches the Thrift IDL definition. RequestMerger is registered through RequestMergerRegistry
for example:
i32 example(1: string in) val requestMerger: RequestMerger[Example.Args] = listArgs => Example.Args(in = listArgs.map(_.in).mkString(";"))
Maintain a map of method name to method's RequestMerger.
A response merger defines the merger function needed to define a Finagle partitioning service for Thrift services.
A response merger defines the merger function needed to define a Finagle partitioning service for Thrift services.
This is used for messaging fan-out, it merges a collection of successful responses and a collection of failures to a final response which matches the Thrift IDL definition. ResponseMerger is registered through ResponseMergerRegistry.
Failing sub-responses are expected to be handled by the application (proper logging, exception handling, etc),
for example:
string example(1: i32 a) val responseMerger: ResponseMerger[String] = (successes, failures) => if (successes.nonEmpty) Return(successes.mkString(";")) else Throw(failures.head)
Maintain a map of method name to method's ResponseMerger.