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

Allow for different effects of HikariTransactor and its creation #1939

Merged
merged 4 commits into from
Dec 18, 2023

Conversation

sideeffffect
Copy link
Contributor

@sideeffffect sideeffffect commented Nov 4, 2023

/cc @piton4k
closes #1902

@mergify mergify bot added the hikari label Nov 4, 2023
@mergify mergify bot added the docs label Nov 6, 2023
@jatcwang
Copy link
Collaborator

jatcwang commented Nov 8, 2023

This is related to #1902 is that right?

@sideeffffect
Copy link
Contributor Author

Oh yes, it is 👍
/cc @lgmyrek

@sideeffffect
Copy link
Contributor Author

@jatcwang 🙏

@jatcwang
Copy link
Collaborator

jatcwang commented Nov 21, 2023

Sorry for the delay. I'm planning to playing around with the provided scenarios (from the issue) to get a better understanding of the need.
A nitpick for now is that Resource[M, HikariTransactor[N]] is ideally Resource[N, HikariTransactor[M]] as most people are used to seeing Transactor[M].

@satorg
Copy link
Contributor

satorg commented Nov 21, 2023

May I add my two cents on this please. I wonder if it was better to create a separate set of functions with two effects instead of introducing breaking changes to the existing ones. Then the existing function could be kept compatible but their implementation could be changed to call the new more generic functions. The reasoning is that I guess likely 90-95% users (or so) do not need the effect separation. I believe it is a good practice in general – to provide simplified functions/methods for most common usages.

@jatcwang
Copy link
Collaborator

Yes I agree that'd be great @satorg :)

@sideeffffect
Copy link
Contributor Author

most people are used to seeing Transactor[M]

Good idea! I've renamed the other type variable to M0.

provide simplified functions/methods for most common usages

It's not worth it. You can always just write

HikariTransactor.fromHikariConfig[IO, IO](hikariConfig)

instead of fromHikariConfig[IO]. It's a trivial change (that you typically need to make just once in your app). Duplicating all the functions just isn't worth the small benefit this would bring.

@satorg
Copy link
Contributor

satorg commented Nov 24, 2023

It's a trivial change (that you typically need to make just once in your app). Duplicating all the functions just isn't worth the small benefit this would bring.

I totally agree that it is not that big deal. However, on the flip side changing existing functions
a. introduces a breaking change urging everyone to take an action upon the next upgrade;
b. introduces the new syntax which the majority of users do not care about.

Needless to say that adding a couple of new functions to the library is not a big deal either. No code duplication necessary there – more common used functions can simply call to more generic but relatively rare used ones. In other words: either do it just once in the library and that's it versus everyone does just once but in each project that uses the library.

That said, I realize that it is absolutely matter of perception which of the two sides outweighs.

@sideeffffect
Copy link
Contributor Author

No code duplication necessary there

Unfortunately it is a lot of code duplication. Majority of the code would be the long function signatures (which you can't reuse in contrast to function bodies). We're in an RC phase, we can afford changes like these.

Of course, if we were stable already, I'd go with the worse, but compatible, way of duplicating the code.

@jatcwang
Copy link
Collaborator

I'm in general agreement with @satorg here. It's best to uphold backwards compatibility and user-friendliness unless our hands are forced.

But I can do the suggested change in a follow-up PR, no problem.

@sideeffffect
Copy link
Contributor Author

I'm afraid that duplicating each method (once with 1 type parameter, once with 2 type parameters) would not be a nice API and very user friendly.

But if that's what you want, I can do that myself. I think I'll have time to do it sometime this week.

@jatcwang jatcwang merged commit 9fa2f52 into typelevel:main Dec 18, 2023
6 checks passed
jatcwang added a commit that referenced this pull request Dec 18, 2023
Partially revert the change in #1939 so that existing code don't fail to compile.
Methods which construct HikariTransactor in a different effect now has the suffix "...SeparateEffect". The original single-effect methods are now implemented in terms of the separate-effect methods.
@sideeffffect sideeffffect deleted the hikari-different-effects branch December 19, 2023 16:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Transactor constructors in 2 effects
3 participants