Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prefix based router support #12

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

tschellenbach
Copy link

Routes based on the configured prefixes

Example config:

'redis': {
    'engine': 'nydus.db.backends.redis.Redis',
    'router': 'django_redis.nydus_router.PrefixPartitionRouter',
    'hosts': {
        'default': {'db': 0, 'host': 'default.redis.goteam.be', 'port': 6379},
        'user:loves:': {'db': 1, 'host': 'default.redis.goteam.be', 'port': 6379},
        'loves:': {'db': 2, 'host': 'default.redis.goteam.be', 'port': 6379},
        'hash:entity:': {'db': 0, 'host': 'entities.redis.goteam.be', 'port': 6379},
    }
}

We route to one and only one redis.
Use a seperate config if you want hashing based partitioning.


'redis': {
'engine': 'nydus.db.backends.redis.Redis',
'router': 'django_redis.nydus_router.PrefixPartitionRouter',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This path needs updated, right?

@dcramer
Copy link
Collaborator

dcramer commented May 16, 2012

I wonder if this would be a good time to add some kind of router options to the configuration.

That could help a lot if we wanted to address #11 by not requiring the dict config approach

"""
Perform routing and return db_nums
"""
assert 'default' in cluster.hosts, 'The prefix router requires a default key to route to'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps I missed something, but is there a default host in your example docstring?

@Fluxx
Copy link
Contributor

Fluxx commented May 16, 2012

Nice work. Can you also add a couple more tests to test the code paths in PrefixPartitionRouter.route() that raise exceptions?

@tschellenbach
Copy link
Author

Awesome, thanks for the very thorough feedback. Good to see such traction behind the project.

We've forked Nydus for 2 reasons.

  • PrefixPartition support
  • Silent failures when using redis as a cache.

Both features are unit tested and included in the pull request.
Hope you guys like the suggestions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants