-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Get rid of peer dependency on loopback-datasource-juggler #275
Comments
Best fix is for the model registry to be provided to a connector/juggler when it is instantiated, so there is no need to mis-use peer deps to attempt to guarantee singleton-ness of the juggler (this doesn't work under a number of conditions). That's an API change, though. For an API compatible fix, I'd suggest doing something like this: in juggler:index.js:
|
I believe the ultimate fix is Dependency Injection :-). Thanks, Raymond Feng StrongLoop makes it easy to develop APIs in Node, plus get DevOps capabilities like monitoring, debugging and clustering. On May 22, 2014, at 11:18 AM, Sam Roberts notifications@github.com wrote:
|
Yes, that's what I am intending to implement. |
I have made the required changes in loopback-connector, loopback-datasource-juggler and loopback-connector-mysql - see the three pull requests listed above this comment. @raymondfeng or @ritch could you please review? I'll modify the remaining connectors after we agree on the right implementation. Note: the change in loopback-datasource-juggler is breaking the API. That should be fine, since we are going to release 2.x soon. However, preserving backwards compatibility is pretty easy. I can modify the PR if we think it's worth it. |
I am closing this issue as done, even though the kafka connector was not updated yet (see the pending pull request haio/loopback-connector-kafka#1). Since the code in kafka connector does not depend on anything from loopback nor loopback-datasource-juggler, its peer dependency on loopback is not a major problem. |
I have reopened the issue. All ground work has been done, but we still need to make the change in loopback's package.json (few minutes of work) and perform a thorough test (that needs more time). |
LoopBack has a peer dependency on loopback-datasource-juggler. As explained in an older comment:
Having multiple instances of juggler is a problem because then there are multiple instances of the global Model registry.
I have looked at several connectors (mysql, postgresql, oracle, rest, soap) and found the following usages of loopback-datasource-juggler:
juggler.ModelBuilder.registerType
to register a custom typePoint
. The call is made frominitialize
.juggler.BaseSQL
I am proposing to make the following changes:
BaseSQL
andConnector
(which is super class of BaseSQL) to a new module (e.g.loopback-connector-base
orloopback-connector
). Modify connectors to use this new module instead of juggler.loopback-connector-base
and exposeBaseSQL
andConnector
classes. This can be removed in the next major version.initialize
function frominitializeDataSource(dataSource, callback)
toinitializeDataSource(dataSource, ModelBuilder, callback)
.The new dependency graph would look like this:
/to @ritch @Raymond what's your opinion on this? I am happy to implement these changes once I get green light from you.
Note: if we are going to release juggler 2.x then it should wait until this change is made, as it allows us to drop juggler dependency on connector base.
Connector check list:
The text was updated successfully, but these errors were encountered: