Overview
This is DependencyProvider for Nameko microservices framework which enables users to work with MongoDb.
First of all I should say that this package based on https://github.com/saiqi/nameko-mongodb . Thank you @saiqi :)
What has been changed:
- Automatic uploading to PyPI by Travis-CI (it was a primary purpose for building of my pet projects)
- Disabled by default results logging
- Some fixes to make this stuff work with new Nameko
Requirements
- Python 2.7 / 3.4 / 3.5 / 3.6 / 3.7
- Nameko 3.11+
- MongoDb :)
Installation
The same as you guessing: pip install nameko-mongodb
How to use
There are some configuration options to use this package (required are in bold):
- MONGODB_CONNECTION_URL - connection URL
- MONGODB_DB_NAME - database name. Default is your service name
- MONGODB_USER - if you need to be authenticated, provide username
- MONGODB_PASSWORD
- MONGODB_AUTHENTICATION_BASE - a source to authenticate. See more information in PyMongo documentation
- MONGODB_AUTH_MECHANISM - see more information in PyMongo documentation
You can use the connection following way:
from nameko.rpc import rpc
import MongoDatabase from nameko_mongodb
class YourService(object):
name = 'your_service'
database = MongoDatabase()
@rpc
def find_item(self):
return self.database.your_collection.find_one()
Also this package can log all executions to logging collection. If you want to use it:
from nameko.rpc import rpc
import MongoDatabase from nameko_mongodb
class YourService(object):
name = 'your_service'
database = MongoDatabase(result_backend=True)
@rpc
def find_item(self):
return self.database.your_collection.find_one()
Sometimes there can be useful to get possibility executing callbacks for DependencyProvider methods (i.e. migrating data when dependency initialized etc.). There are some callbacks:
on_before_setup: (instance)on_after_setup: (instance)on_before_stop: (instance)on_after_stop: (instance)on_before_worker_setup: (instance, worker_ctx)on_after_worker_setup: (instance, worker_ctx)on_before_worker_result: (instance, worker_ctx, result, exc_info)on_after_worker_result: (instance, worker_ctx, result, exc_info)
How to use callbacks:
from nameko.rpc import rpc
import MongoDatabase from nameko_mongodb
class YourService(object):
name = 'your_service'
database = MongoDatabase(
on_before_setup=lambda x: print("Start setup DP"),
on_after_setup=lambda x: print("Stop setup DP"),
)
@rpc
def find_item(self):
return self.database.your_collection.find_one()
Contribution
I'd be glad to see your pull requests
Metadata
Release files for nameko-mongodb 1.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| nameko-mongodb-1.1.1.tar.gz | 3.7 kB | Without provenance | Details for nameko-mongodb-1.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| nameko_mongodb-1.1.1-py3-none-any.whl | Python 3 | none | any | Details for nameko_mongodb-1.1.1-py3-none-any.whl |
Total release size: 11.7 kB
Release files / nameko-mongodb-1.1.1.tar.gz
| Download URL | nameko-mongodb-1.1.1.tar.gz |
|---|---|
| Size | 3.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e47dc208c3271c7a2ad407f6ee944f2125f42d67d98c0d114c3928c72e2844c4
|
|
BLAKE2b-256 checksum How to use checksums |
6e5691a8cd025ce146c866e9564223f47cea6d2f4a311667aa15f554d1fca0ca
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/40.6.2 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.1
|
Release files / nameko_mongodb-1.1.1-py3-none-any.whl
| Download URL | nameko_mongodb-1.1.1-py3-none-any.whl |
|---|---|
| Size | 8.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d1fcc3c50dd064f27f27fe183b3ec50d84232b8a15591b54066c546f4830e31b
|
|
BLAKE2b-256 checksum How to use checksums |
906ef8303d1597d9c8e4fcadcc2fccc697a172ccdb9622fdd3d1a8be488a721c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/40.6.2 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.1
|
Security for nameko-mongodb 1.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.