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 Mongodb driver #94

Closed
wants to merge 11 commits into from
Closed

Add Mongodb driver #94

wants to merge 11 commits into from

Conversation

iampersistent
Copy link
Contributor

No description provided.

@GromNaN
Copy link
Contributor

GromNaN commented Jan 21, 2014

Out of curiosity, what would be the advantage of this compared to the other drivers?

- MONGO_VERSION=1.3.2
- MONGO_VERSION=1.4.4

services: mongodb
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to change the test cases to use mocking instead of a real database?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've started working on the mocks, but it will be tomorrow before I can get back to them.

@henrikbjorn
Copy link
Contributor

Great job, have made some comments on the code :)

@iampersistent
Copy link
Contributor Author

@GromNaN for me, the advantage is I can use the same db that I'm using for the rest of my site without needing to install a proper queue system until the traffic demands it.

{
$this->db = $db;
$this->collection = $db->selectCollection('bernardMessages');
$this->queueCollection = $db->selectCollection('bernardQueues');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would prefer bernard_messages and bernard_queues as the other drivers. Also i dont know if it is needed to create the collections upfront. What do you think about using $db->bernard_messages when we need the collection ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or instead call the variables $this->messages and $this->queues

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine with changing the names. If we are not going to create the collections upfront, then we would need to call a method to get the message and queue collections to make sure we have selected the collection.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This class doesn't seem to use $db at all. Why not just construct it with the actual MongoCollection dependencies? That would (a) allow the user to specify whatever collection names they like and (b) make testing easier, since you could do away with mocking MongoDB::selectCollection() on top of the collections themselves.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine with that if @henrikbjorn is ok with me approaching it that way. It is a bit of a PITA to mock MongoDB::selectCollection()

@@ -26,7 +26,8 @@
"symfony/serializer" : "~2.2",
"doctrine/dbal" : "~2.3",
"iron-io/iron_mq" : "~1.4",
"aws/aws-sdk-php" : "~2.4"
"aws/aws-sdk-php" : "~2.4",
"ext-mongo" : ">=1.2.12,<1.6-dev"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your documentation example uses MongoClient. Honestly, I'd suggest just making this >=1.3.0 so there's no need to even support or test the deprecated Mongo class. The only reason we allow this in doctrine/mongodb is for BC.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm okay with doing this. @henrikbjorn ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

im okay with requirering >=1.3.0

@iampersistent
Copy link
Contributor Author

I haven't forgotten this, I've just been pulled away from it for the time being. I'll circle back around to it when I can.

@Baachi
Copy link
Contributor

Baachi commented Aug 12, 2014

Any news?

@iampersistent
Copy link
Contributor Author

Nothing new on this. Are you needing it? If so, I can make it a higher priority on my todo list.

@sagikazarmark
Copy link
Contributor

I would be happy to see this merged.

@henrikbjorn
Copy link
Contributor

Several people have showed interest in getting this merged. @iampersistent anything new? I have lost track of this driver :)

@sagikazarmark
Copy link
Contributor

As I can see it is using the PECL extension. It would be awesome if it could be built like the redis driver: using the extension and a "native" implementation as well. There is a cool one originally created by @FrenkyNet called Monga. Might worth a check.

@jmikola
Copy link
Contributor

jmikola commented Dec 2, 2014

@sagikazarmark: AFAIK, Monga is just an abstraction around the PECL extension, much like Doctrine MongoDB. A "native" implementation of a MongoDB driver in PHP would be mongofill.

@jmikola
Copy link
Contributor

jmikola commented Dec 2, 2014

@iampersistent: If you're too busy, I can try to take this on by rebasing and opening a new PR. Shouldn't take more than an hour or two, since you've already done most of the work. Let me know.

@iampersistent
Copy link
Contributor Author

@jmikola thanks, I really appreciate you offering to do that. Do what ever you need and ping me if you have any questions.

@frankdejonge
Copy link

@jmikola Hi Jeremy :) just popped in to say your assumptions are correct. It's only a "fancy" query builder.

@henrikbjorn
Copy link
Contributor

Would it make sense to move this into its own repo? then it could contain drivers for Mongofill, ext-mongo and maybe other simple abstractions?

@jmikola
Copy link
Contributor

jmikola commented Dec 3, 2014

@henrikbjorn: Mongofill implements the same API as the PECL driver (it defines the same non-namespaced classes), so I don't think we need to write more than a single class. It's up to you if you'd like it in a separate repository though, but I doubt the finished product will look much different than the current PR.

@jmikola jmikola mentioned this pull request Dec 7, 2014
@henrikbjorn
Copy link
Contributor

Closed as #133 is now merged, thanks for your work on this anyway :)

@henrikbjorn henrikbjorn closed this Jan 4, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants