A wrapper for using nameko services with Flask
Project description
# flask_nameko
A wrapper for using nameko services with Flask
## Installation
Install it via Clef's PyPI:
pip install flask_nameko
## Usage
To start using `flask_nameko`, you need to create and configure a new `FlaskPooledClusterRpcProxy` singleton, which you'll use to communicate with your Nameko cluster.
# __init__.py
from flask import Flask
from flask_nameko import FlaskPooledClusterRpcProxy
rpc = FlaskPooledClusterRpcProxy()
def create_app():
app = Flask(__name__)
app.config.update(dict(
NAMEKO_AMQP_URI='amqp://localhost'
))
rpc.init_app(app)
app = create_app()
Then, you can use the `FlaskPooledClusterRpcProxy` singleton just as you would normally use a `ClusterRpcProxy`, by accessing individual services by name and calling methods on them:
# routes.py
from . import (
app,
rpc
)
@app.route('/'):
def index():
result = rpc.service.do_something('test')
return result
## API
### Configuration
`FlaskPooledClusterRpcProxy` accepts all nameko configuration values, prefixed with the `NAMEKO_` prefix. In addition, it exposes additional configuration options:
* `INITIAL_CONNECTIONS (int, default=2)` - the number of initial connections to the Nameko cluster to create
* `MAX_CONNECTIONS (int, default=8)` - the max number of connections to the Nameko cluster to create before raises an error
### Proxies
*flask_nameko.**FlaskPooledClusterRpcProxy**(app=None)*
This class is used to create a pool of connections to a Nameko cluster.
*init_app(app=None)*
Configure the proxy for a given app.
## Development
$ git clone git@github.com:clef/flask_nameko.git flask_nameko
$ cd flask_nameko
$ make develop
=======
History
=======
`0.1.0 <https://github.com/clef/flask-nameko/compare/89698bba0ece0781f931b006009d3b3468e7883a...v0.1.0>`__ (2016-07-28)
-----------------------------------------------------------------------------------------------------------------------
Features
~~~~~~~~
- **flask\_nameko**: adds FlaskPooledClusterRpcProxy
(`285df05 <https://github.com/clef/flask-nameko/commit/285df05>`__)
0.1.0
------------------
* First release on PyPI.
A wrapper for using nameko services with Flask
## Installation
Install it via Clef's PyPI:
pip install flask_nameko
## Usage
To start using `flask_nameko`, you need to create and configure a new `FlaskPooledClusterRpcProxy` singleton, which you'll use to communicate with your Nameko cluster.
# __init__.py
from flask import Flask
from flask_nameko import FlaskPooledClusterRpcProxy
rpc = FlaskPooledClusterRpcProxy()
def create_app():
app = Flask(__name__)
app.config.update(dict(
NAMEKO_AMQP_URI='amqp://localhost'
))
rpc.init_app(app)
app = create_app()
Then, you can use the `FlaskPooledClusterRpcProxy` singleton just as you would normally use a `ClusterRpcProxy`, by accessing individual services by name and calling methods on them:
# routes.py
from . import (
app,
rpc
)
@app.route('/'):
def index():
result = rpc.service.do_something('test')
return result
## API
### Configuration
`FlaskPooledClusterRpcProxy` accepts all nameko configuration values, prefixed with the `NAMEKO_` prefix. In addition, it exposes additional configuration options:
* `INITIAL_CONNECTIONS (int, default=2)` - the number of initial connections to the Nameko cluster to create
* `MAX_CONNECTIONS (int, default=8)` - the max number of connections to the Nameko cluster to create before raises an error
### Proxies
*flask_nameko.**FlaskPooledClusterRpcProxy**(app=None)*
This class is used to create a pool of connections to a Nameko cluster.
*init_app(app=None)*
Configure the proxy for a given app.
## Development
$ git clone git@github.com:clef/flask_nameko.git flask_nameko
$ cd flask_nameko
$ make develop
=======
History
=======
`0.1.0 <https://github.com/clef/flask-nameko/compare/89698bba0ece0781f931b006009d3b3468e7883a...v0.1.0>`__ (2016-07-28)
-----------------------------------------------------------------------------------------------------------------------
Features
~~~~~~~~
- **flask\_nameko**: adds FlaskPooledClusterRpcProxy
(`285df05 <https://github.com/clef/flask-nameko/commit/285df05>`__)
0.1.0
------------------
* First release on PyPI.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
flask_nameko-1.0.0.tar.gz
(5.4 kB
view hashes)