Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proxy Method to require a different return type on error (not a throwable) #12

Open
rmmeans opened this issue Feb 8, 2018 · 4 comments

Comments

@rmmeans
Copy link
Contributor

rmmeans commented Feb 8, 2018

I'm curious to hear your take on this.

So far we love your library, and our primary use case is using it with API Gateway and SAM to deploy serverless Scala based API's. Our problem is that we are wanting to use the Lambda Proxy invocation as it is the easiest to use from an API Gateway perspective. This works great with your library on the happy path for the Lambda.Proxy impl - but on the failure path, I need to be able to grab a hold of that failure and have full control of the ProxyResponse that is returned. When using the Proxy return style, I do not want Throwables as the Lambda payload that is returned would end up going all the way as-is through the API gateway and back to the caller. This would end up being a different type than ProxyResponse[O] as the happy path return type can't be generated in the error scenario. I think what I would want for the the output on error is a type of a ProxyResponse[E] (e for error type), or something similar. Thoughts?

@mkotsur
Copy link
Owner

mkotsur commented Feb 17, 2018

Hi @rmmeans. Apologies for late reaction. I think, what you want makes total sense. As you might have noticed, the library is built mostly around the happy path and there are neither facilities nor documentation regarding error handling. I would be happy to change that now that someone wants it.

I’ve been looking into allowing to return different types (e.g. Future[O] instead of O) from the handler using implicit conversions underneath.

While not exactly the same, this mechanism could open the doors for the error handling facilities you want. Let me do some hacking during this weekend and I’ll come up with some proposal early next week.

@rmmeans
Copy link
Contributor Author

rmmeans commented Feb 17, 2018

No worries, sounds good!

We have actually been hacking on our variation of this problem from scratch as well using as little of libraries as we can (e.g. no Circe automatic derivation - everything is done with custom encoders / decoders in the lib, etc.) so we can keep the overall jar size down for the library itself... users could still use the automatic for their types if they wish to pull in more dependencies.

I hope to open source what we've done next week sometime with a beta release. Our initial scope is very narrow - only focusing on API Gateway Proxied responses and building a nice type system for a developer to deal with that setup.

@rmmeans
Copy link
Contributor Author

rmmeans commented Feb 21, 2018

We have open sourced our take on this problem. https://github.com/lifeway/scala-aws-lambda-handler I gave you credit for the inspiration in the README.

We'll be getting the first release of it out to maven central hopefully tomorrow.

@mkotsur
Copy link
Owner

mkotsur commented Feb 27, 2018

Hey @rmmeans. Nice, good luck with that. For me it's still an interesting challenge to support both: proxy and plain lambdas in the same library.

I'll take some more time before making the change: considering a couple different alternatives how to implement it, and the time I can spend on this project is pretty limited... Will let you know when it's done, of course :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants