flipkart-incubator / phantom

Phantom is a high performance proxy for accessing distributed services. It is an RPC system with support for different transports and protocols. Phantom is inspired by Twitter Finagle clients and builds on the capabilities of technologies like Netty, Unix Domain Sockets, Netflix Hystrix and Spring. Phantom proxies have been used to serve several hundred million API calls in production deployments at Flipkart.
49 stars 27 forks source link

Support generic return type in TaskHandler's execute() #55

Closed pmohankumar closed 8 years ago

pmohankumar commented 8 years ago

Support generic return type in TaskHandler's execute() and HystrixTaskHandler's getFallBack()

TaskHandler's execute (without decoder) method's return type is not a generic type (its byte[]). TaskHandlers to data stores might get deserialized Objects directly from the datastore client (say couchbase client using WhalinTranscoder decompresses and deserializes the fetched data as Java Object). Because of TaskResult<byte[]> restriction, such task handlers are forced to not use data store client's in-built deserialization mechanisms or in the worst case, serialize an already deserialized Object back to byte[] which adds one extra serialization-deserialization loop in each request.

Even the sample ArithmeticTaskHandler is converting the float to String and sending the result in message String. Ideally it shouldn't convert float to string or byte[]. It should just send float as it is as TaskResult's data.