ubervu / mongo-pool Goto Github PK
View Code? Open in Web Editor NEWAll your mongos in one place
License: Apache License 2.0
All your mongos in one place
License: Apache License 2.0
As a developer
I want to be able to use as much code as possible from an open-source project instead of rewriting it
So that I use it at its full potential, avoid reimplementing things and copy-paste code
Make getattr method easier to be extended
Break getattr logic in two parts. One that gets the connection to the cluster based on the name of the database to be accessed and one that returns the database from the cluster. This way, both can be modified to add functionality.
This will enable us to use proper inheritance in private MongoPool
>>> blogs = mongopool.blogs
>>> blogs
Database(MongoClient('127.0.0.1', 27017), u'blogs')
>>> posts = mongopool.posts
>>> posts
Database(MongoClient('127.0.0.1', 27017), u'posts')
the same as?
>>> mongopool.blogs
Database(MongoClient('127.0.0.1', 27017), u'blogs')
>>> mongopool.posts
Database(MongoClient('127.0.0.1', 27017), u'posts')
/cc @claudiu-coman
As a developer
I want my packages to follow the naming convention
So that I can import them as expected
PR #26
Passing optional arguments based on their position produces confusion because you might forget what does a certain value stand for and can lead to hard to find bugs if the method signature is changed.
To avoid these situations, it is better to pass arguments as keyword arguments.
def foo(a, b=None)
Wrong
foo(2, 3)
Better
foo(2, b=3)
Since the code already has nice, formatted docstrings, we should take advantage and host the docs on http://readthedocs.org/, as most serious python projects do.
cc @bgdnc @claudiu-coman
As a developer
I want an easy way to get a connection to a cluster based on its label
So that I can reuse connections
As a developer
I want to be prompted as early as possible if the configurations provided are not valid
So that potential problems are discovered at instantiation rather than later when trying to access a database
Scenario: Providing faulty configurations
Given I pass configurations that are not valid
When I try to instantiate MongoPool
Then an exception should be raised
Write 2 private methods that validate mandatory configs parameters and optional ones
As a developer
I want a mechanism to manage multiple mongo connections to different clusters and map databases to connections
So that I won't be forced to remember the host and the port and create a connection each time I want to work with a database on a different cluster and write those details in a single place
Scenario: Working with databases on multiple clusters
Given I have to work with some databases located on different clusters
And I write connection information in a configuration file
When I want to access a database
Then I can access the wanted database based solely on it's name
A class MongoPool that keeps internally a list with database information (host, port, read preference, database name).
When the user wants to access a database, all he has to do is mongopool.db_name. Behind the scene, it will create a connection to the correct cluster and return the database. To make it accessible as a simple attribute, the __getattr__
method will be implemented.
As a developer
I want the timeout set for each each mongo connection to have an adequate value
So that it kills lagging connections, but doesn't affect connections that take a little longer
## Deliverables
- [ ] have the timeout set in seconds instead of miliseconds
As a developer
I want to provide the 'host' value of a cluster in the config as a list of hosts
So that I can connect to replicaSets
Given I have an entry in the configuration file that sets 'host' to a list of hosts
When I instantiate MongoPool
Then MongoPool will accept the config as valid
Write a sample config file to serve as a starting point for using mongopool.
As a developer
I want to be able to pass a custom connection class to mongopool to use for connecting to the mongo instance
So that I can have better control over the connection (for example, create a self reconnecting connection)
Add 2 private attributes to MongoPool that hold the classes to create a simple connection and a connection to a replicaSet
Set the version of mongopool to 0.2 on setup.py
A declarative, efficient, and flexible JavaScript library for building user interfaces.
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. πππ
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google β€οΈ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.