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

WIP: Introduce operation concept and client pool #219

Closed
wants to merge 4 commits into from

Conversation

mbroadst
Copy link
Member

This change set introduces a concept of an "operation" to our codebase, allowing us to abstract calls to libmongoc in order to do things like use a client pool, or asynchronously run the operation on a thread pool. I threw in the client pool to show how it can be used, maintaining existing behavior by reserving one client from the pool for things that haven't been converted to operations yet.

Now we have a generic method for executing things that conform to
the `Operation` protocol. This allows us to do many interesting
things, most notably pop clients off a pool and use them for
operation execution.
A few things going on here. First, a new type `MongoNamespace` was
introduced to make it easy to track the current namespace without
needing to necessarily pass collections or databases around.
Secondly, execution is now passed a pointer to the `mongoc_client_t`
so that we can create the `mongoc_collection_t` or `mongoc_database_t`
at the moment of execution, this allows us to avoid most of the
pitfalls of lack of thread safety in libmongoc.
This changes introduces a client pool into the `MongoClient` ctor.
Of note is that the pool is currently only used for two operations
which have been converted to `Operation` subclasses (insertOne,
updateOne), and it maintains behavior for all other operations by
popping a client at init, and pushing it back before close.
@kmahar
Copy link
Contributor

kmahar commented Apr 2, 2019

is it possible to convert this to a draft, or can it not be reversed once it's "ready for review"?

@mbroadst
Copy link
Member Author

mbroadst commented Apr 3, 2019 via email

@mbroadst mbroadst closed this Apr 3, 2019
@kmahar kmahar deleted the operation-experiment branch September 23, 2019 22:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants