This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description

Flask-Redis-Sentinel provides support for connecting to Redis using Sentinel and also supports connecting to Redis without it.

  • Supports Python 2.7 and 3.3+
  • Licensed using Apache License 2.0

Installation

Install with pip:

pip install Flask-Redis-Sentinel

Basic usage

from flask_redis_sentinel import SentinelExtension

redis_sentinel = SentinelExtension()
redis_connection = redis_sentinel.default_connection

# Later when you create application
app = Flask(...)
redis_sentinel.init_app(app)

You can configure Redis connection parameters using \(REDIS_URL\) Flask configuration variable with \(redis+sentinel\) URL scheme:

redis+sentinel://localhost:26379[,otherhost:26379,...]/mymaster/0
redis+sentinel://localhost:26379[,otherhost:26379,...]/mymaster/0?socket_timeout=0.1
redis+sentinel://localhost:26379[,otherhost:26379,...]/mymaster/0?sentinel_socket_timeout=0.1
redis+sentinel://:sentinel-secret-password@localhost:26379[,otherhost:26379,...]/mymaster/0?sentinel_socket_timeout=0.1

The extension also supports URL schemes as supported by redis-py for connecting to an instance directly without Sentinel:

redis://[:password]@localhost:6379/0
rediss://[:password]@localhost:6379/0
unix://[:password]@/path/to/socket.sock?db=0

Flask-And-Redis style config variables are also supported for easier migration, but the extension will log a \(DeprecationWarning\):

REDIS_HOST = 'localhost'
REDIS_PORT = 6379
REDIS_DB = 0

In case both \(REDIS_URL\) and other variables are present, the URL is used.

Creating multiple connection pools using a single Sentinel cluster

from flask_redis_sentinel import SentinelExtension

redis_sentinel = SentinelExtension()
master1 = redis_sentinel.master_for('service1')
master2 = redis_sentinel.master_for('service2')
slave1 = redis_sentinel.slave_for('service1')

Accessing redis-py’s Sentinel instance

from flask_redis_sentinel import SentinelExtension
from flask import jsonify, Flask

app = Flask('test')

redis_sentinel = SentinelExtension(app=app)

@app.route('/')
def index():
    slaves = redis_sentinel.sentinel.discover_slaves('service1')
    return jsonify(slaves=slaves)

Change log

v1.0.0

  • Moved URL handling code to a separate library, \(redis_sentinel_url\)

  • Backward-incompatible change:

    # Old
    redis+sentinel://host:port/service?slave=true
    

    Should now be written as:

    # New
    redis+sentinel://host:port/service?client_type=slave
    

v0.2.0

  • Use config variables other than \(REDIS_{HOST, PORT, DB}\) even if \(REDIS_URL\) is used
  • Minor refactoring

v0.1.0

  • Initial release
Release History

Release History

1.0.0

This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.2.0

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.1.0

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
Flask_Redis_Sentinel-1.0.0-py2.py3-none-any.whl (4.9 kB) Copy SHA256 Checksum SHA256 py2.py3 Wheel Aug 24, 2016
Flask-Redis-Sentinel-1.0.0.tar.gz (8.2 kB) Copy SHA256 Checksum SHA256 Source Aug 24, 2016

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting