Skip to content

Commit

Permalink
Integration of MongoDB storage driver.
Browse files Browse the repository at this point in the history
  • Loading branch information
mborho committed Jun 26, 2017
1 parent 892dbaa commit e33edde
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
10 changes: 7 additions & 3 deletions livebridge/components.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# limitations under the License.
import logging
from livebridge import config
from livebridge.storages import DynamoClient, SQLStorage
from livebridge.storages import DynamoClient, SQLStorage, MongoStorage


logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -78,9 +78,13 @@ def add_target(cls):


def get_db_client(**kwargs):
if kwargs.get("dsn") or config.DB.get("dsn"):
dsn = kwargs.get("dsn") or config.DB.get("dsn")
if dsn:
params = config.DB if not kwargs else kwargs
return SQLStorage(**params)
if dsn.startswith("mongodb://"):
return MongoStorage(**params)
else:
return SQLStorage(**params)
# default dynamodb
params = config.AWS if not kwargs else kwargs
return DynamoClient(**params)
1 change: 1 addition & 0 deletions livebridge/storages/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@
from livebridge import config
from livebridge.storages.dynamo import DynamoClient
from livebridge.storages.sql import SQLStorage
from livebridge.storages.mongo import MongoStorage
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ aiobotocore==0.3.3
aiohttp==2.1.0
asynctest==0.10.0
bleach==2.0.0
dsnparse==0.1.4
motor==1.1
pytest==3.1.2
pytest-cov==2.5.1
python-dateutil==2.6.0
Expand Down

0 comments on commit e33edde

Please sign in to comment.