iopipe-java icon indicating copy to clipboard operation
iopipe-java copied to clipboard

Make `GenericAWSRequestHandler` do the JSON deserialization and handler calling

Open XerTheSquirrel opened this issue 7 years ago • 1 comments

The raw JSON data is passed in the entry point implements RequestStreamHandler. Since this gives access to the raw JSON data, we can handle JSON deserialization ourselves and then support calling into either RequestHandler or just forwarding the streams to RequestStreamHandler.

This will have the advantage of doing JSON deserialization any way we want rather than forcing how Amazon does it.

This will break compatibility if any other code uses GenericAWSRequestHandler as a RequestHandler (a wrapper on top of IOpipe?).

This should be researched.

XerTheSquirrel avatar Aug 31 '18 22:08 XerTheSquirrel

I had a thought that compatibility is no issue at all, these are two different interfaces and they can be implemented since they provide two different methods (they have different descriptors). This means:

  • Does not break compatibility.
  • GenericAWSRequestHandler implements both RequestHandler and RequestStreamHandler.
  • AWS should prefer the stream based handler, which may be faster.
  • Existing code that uses RequestHandler it will still work.
  • The generic handler, at least the code being used, I believe the library it uses serializes to JSON then deserializes that to the target object. If this is actually how it works, then this would reduce latency to handling the events.

If this is done, then there would have to be an internal extra method which forwards to the desired code to be executed, to prevent the input object being processed multiple times.

XerTheSquirrel avatar Sep 19 '18 19:09 XerTheSquirrel