-
Notifications
You must be signed in to change notification settings - Fork 56
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 with dynamic connection #271
Conversation
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.
Instead of adding this to the module property, i think this should be an option for the cli command?
--db=xyz
I will add the command parameter later. At first I would to implement only the connection to make it configurable via config file. The |
To be honest i really believe this should not belong to the Module, this is not something which should be configured in the Module as we are also not going to do this in other situations (for other commands). It should not be a big deal to change. Also the Yii Framework commands work like this, so we should follow those "best practice" behaviors: |
What i saw just now is that you are also use this component definition for the API - so you think even the API side needs to have configurable database component? Could you make an use case where this is needed? Maybe we should define the use case very quickly and check the best solution. |
My case is to sync two magento databases. For that I want to run the client on a staging/test environment and the api-proxy on production env. The client need the db connection to the staging db and the api to production db. Both of them should not have an other option to system with other db. |
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.
I think the admin side (api) is a good idea to configure via module, please use instance::ensure instead - everything else looks good now.
For the client (the one which actually runs the sync command) we should have the --db=xyz option instead of a config.
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.
- The ensure should work like
$db = 'db'
see https://www.yiiframework.com/doc/api/2.0/yii-di-instance. - Decide whether the db connection object for the console command should be done in ClientBuild or the Command itself and pass to the ClientBuild object.
- The object would be passed to ClientTable as well, in order to ensure its a database object we could also use a getter/setter method in ClientTable and ClientBuild setDb(Connection $db) which ensures the correct instance is provided.
Thanks for your work, its harder topic then i thought. So to summarize it again:
- The server can specific the db connection trough admin module: proxyConnectionName (maybe using proxyDbConnection?)
- The client can change the database (where the data should be stored) only with --db=xyz
We are very close to 2.0 release, is there something i can provide on this PR in order to finish it soon? Let me know if we should resolve all conversations and take a "new" look. |
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.
This should be the finally review i assume :-)
Regarding class names: Its not a change from this PR, but it would be nice to always add classes into use statments (example: \yii\db\mysql\Schema)
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.
Please change the getter setter behavior and add the @Property phpdoc annotation. Everything else looks good and we are ready to merge afterwards. Would be nice to do this asap, otherwise we have to move this feature to version 2.1.0
Thanks for taking time @boehsermoe! |
What are you changing/introducing
Replaced all
Yii::$app->db
usage with$this->db
.@nadar i merged unintentionally my master with #270, after that merged it should be fine.
What is the reason for changing/introducing
Can use a other database connection for the proxy sync. So you can sync any database also from a other system.
QA