-
Notifications
You must be signed in to change notification settings - Fork 364
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
Part 1 of moving tx timeout and id to connector #1484
Part 1 of moving tx timeout and id to connector #1484
Conversation
Regarding |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lehni Technically, the extension of the if statement to incorporate a check against the transaction's timeout property constitutes a "new code path" of sorts, which is what coveralls is probably complaining about. That being said, since this isn't a breaking change, and is meant as a stop-gap to avoid breakage with subsequent PRs, I'm okay with the small decrease.
One additional note: Coveralls seems to experience rounding errors with sufficiently large code bases; I've had it report coverage decreases, only to re-run the tests again and have it report that there was no change in coverage. (I'm not certain that this is the case, but I've seen it happen and couldn't come up with an alternative explanation.) |
@lehni Please reword the commit message to be about the change as it stands; something like "transaction: bind timeout to tx instance" and then I'll land this. |
@kjdelisle great! I've adjusted this now. Thanks! |
After further looking into transactions in There is a whole lot of monkey-patching going on in VS: I would like to suggest to create another pair of PRs that moves it all to Before I embark on this, I'd like to hear thoughts on the proposal... @kjdelisle, @bajtos, @ssh24 does this sound reasonable? |
* Add a better way to handle transactions (Jürg Lehni) * validations: use new regex per evaluation (#1479) (Joost de Bruijn) * Transaction: Bind timeout to tx instance (#1484) (Jürg Lehni) * CODEOWNERS: add lehni (#1483) (Miroslav Bajtoš) * Add node8 support for travis (loay) * Add nyc coverage, report data to coveralls.io (Miroslav Bajtoš) * Update translations from TVT (Allen Boone) * Add test coverage for hasAndBelongsToMany (loay) * package: use qs@6.5.0 (#1471) (Kevin Delisle)
I think that sounds good. You've already thought of the idea of enforcing the mutual dependency to protect the API integrity for end-users. We'll find out regardless once the downstream dependencies run in CI. |
After looking more into it, I realised that things are a bit more complicated unfortunately: As part of the monkey-patching, the And So what we could do is move everything else over to I am not sure what's better? |
The first option would be better, mostly because the juggler is not a dependency of the connector base (it's only a dev dep for testing purposes). |
I have mixed feelings about moving
Setting aside design purity, there are also practical implications. For example, consider the following dependency tree (using the latest versions as of this writing):
In the original design, the sqlite datasource and attached models will be using the latest code for things that are not connector specific (like Now my concern with moving generic stuff from juggler to connector is that once done, we can end up in a situation where the connector relying on an older version of In an ideal world, I think the solution to these problems would be to decouple Transaction/ObserverMixin from juggler even more and ship them as standalone packages ( Also, maybe Uh oh. I am not sure what's the best next step here. I guess we can either move
I think this is definitely not the option, one of the reasons is that we will have circular dependency (juggler's memory connector depends on loopback-connector which depends on juggler). Another alternative comes to my mind: can we perhaps inject |
Not really, because the Right now, I agree that creating a new Does that make sense? Another options could be to start a |
Makes sense, thank you for explaining it!
I am not familiar enough with juggler to fully comprehend what do you mean by monkey-patching Transactions, but hearing the phrase monkey-patching makes me want to do what you propose :)
Perhaps. The downside of such module is that over time, it may become a kitchen sink for utility functions, and then we will have hard times making breaking changes, because everybody will be depending on this module. We went through a similar process with Regardless of the approach we decide to take, I'd like to propose to keep working incrementally in baby steps, making one change at a time. This will make it easier to review and land the pull requests, and if our priorities later happen to shift elsewhere, then we will have at least part of this work done done. |
@bajtos I agree with all of this. Just quickly to explain the monkey-patching part:
And I don't think that's good practise, but a recipe for confusion and disaster :) |
@bajtos so I'd like to tackle this one now.
So that's a clear argument for a separate The other option is Either way, how would I go about creating such a package? |
Yes :)
That's always the problematic part of "many small modules" philosophy.
I guess that's a reasonable compromise 👍 Considering that the next major version of LoopBack will be based on entirely new codebase (see https://github.com/strongloop/loopback-next), I think the overhead of creating multiple smaller packages (one for the observer, another for other utility functions) is not worth the effort at this moment. @raymondfeng @kjdelisle what's your opinion?
One of GitHub org admins like me, @kjdelisle or @raymondfeng need to create a new GH repository and setup permissions so that you have write access (I think we should give write access to everybody who has write access to loopback, juggler and remoting now.) Then you can start the usual pull-request based development. We need to agree on the package name - is |
Sounds all good! I would suggest using the plural |
@raymondfeng @kjdelisle @bajtos @raymondfeng I'm hoping for feedback here so we can wrap this up. Please let me know your thoughts, thanks! |
@lehni I'm good with the plural form (we already do it for things like |
@kjdelisle thanks! I'm about to leave on a mini-holiday, will start working on this when back next week. |
@lehni no worries, take your time. When you get to this work, could you please start with a pull request setting up the project infrastructure? Mocha tests, eslint, Travis config, etc. I'll enable Travis CI builds right now. |
@kjdelisle @bajtos I think we have a naming clash 😞 https://www.npmjs.com/package/loopback-utils What to do? |
Other than that, I think my code is ready for review at https://github.com/strongloop/loopback-utils/tree/feature/add-utils-from-juggler |
As for the naming issue... What about Another option is |
@lehni let me know what name do you like best, so that I can rename the new repo. |
I like |
Description
This simple PR is part one of moving the handling of transaction timeouts and ids from
loopback-datasource-juggler
'sTransactionMixin.beginTransaction()
toloopback-connector
'sTransaction.begin()
, where it makes more sense and can be leveraged more easily by other parts of the code, e.g. the work I am doing in #1472. For a more detailed description of the motivation to do so, see #1472 (comment)By itself, this does not change anything yet, it just adds support for moving / (duplicating for the time being) the functionality in
loopback-connector
, without calling thetimeout
observers twice.As the comment in this PR suggests, we should keep this code around for quite a while and eventually remove it:
I don't think additional tests are required.
Related issues
Checklist