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

Add option to generate higher-kinded-type service interface #352

Open
henryxparker opened this issue Jan 18, 2022 · 2 comments
Open

Add option to generate higher-kinded-type service interface #352

henryxparker opened this issue Jan 18, 2022 · 2 comments
Labels

Comments

@henryxparker
Copy link

Is your feature request related to a problem? Please describe.
A recent release has removed the higher-kinded-type (HKT) interface when generating services (i.e. it removed the option to write Service.MethodPerEndpoint as Service[Future]). This change has excluded an existing use-case described in the comments on that commit. For brevity I will paraphrase it here:

Not everyone prefers to use twitter Futures, and the HKT interface allows you to easily change to a different F. i.e. we can turn a Service[twitter.util.Future] into a Service[scala.concurrent.Future] by providing the function* twitter.util.Future => scala.concurrent.Future. That allows us to work directly in our chosen F until we need to convert everything back to twitter Futures for finagle.

Describe the solution you'd like
There should be an option to generate the HKT interface for services. Either through a plugin or a flag. The main impetus behind the original commit seems to have been to reduce the total amount of generated code. Thus a plugin/flag would allow most to benefit from the reduced code volume, and allow others to use the interface if needed.

Footnotes:

  • That's technically a "Natural Transformation" (~>), not a function (=>)
henryxparker referenced this issue Jan 18, 2022
Problem

FutureIface is deprecated.
Scrooge is more powerful when used with finagle integration,  and in that case, higher-kinded-types won't play its advantages.
Scrooge generated code is growing which increases source compilation time, we should get rid of the unused parts.

Solution

Remove them from code-gen.
In generated code, replace HKT/FutureIface with MethodPerEndpoint.
Remove some deprecated builders in both scrooge-gen and finagle that require HKT as the parameter.

Differential Revision: https://phabricator.twitter.biz/D747744
@joybestourous
Copy link
Contributor

hey @henryxparker, our team is taking a look at this to see what we can do for you folks. we'll reach out to you when we have updates. thanks!

@henryxparker
Copy link
Author

Update on our side: we created a library for generating higher-kinded types from the scrooge output using scalafix, and an sbt plugin that does it under the hood. It's not a perfect solution, but it will work if anyone else is having the same problem.
I'll leave this open in case you want to add support for higher-kinded types back into scrooge in some way, but feel free to close it.

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

No branches or pull requests

3 participants