Skip to content
This repository has been archived by the owner on Aug 21, 2020. It is now read-only.

Commit

Permalink
Fix the watch prefix bug
Browse files Browse the repository at this point in the history
The watch API cannot work properly. When you set up a key prefix,
it will still watch the whole key space. This commit fixes it.

The reason is that when it deals with the original key prefix string,
it double encodes the string in client.py and watch.py.
  • Loading branch information
skywalker-nick authored and dims committed Nov 24, 2017
1 parent 3504ef1 commit 309df0c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions etcd3gw/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ def iterator():
def watch_prefix(self, key_prefix, **kwargs):
"""The same as ``watch``, but watches a range of keys with a prefix."""
kwargs['range_end'] = \
_increment_last_byte(_encode(key_prefix))
_increment_last_byte(key_prefix)
return self.watch(key_prefix, **kwargs)

def watch_once(self, key, timeout=None, **kwargs):
Expand All @@ -392,7 +392,7 @@ def callback(event):
def watch_prefix_once(self, key_prefix, timeout=None, **kwargs):
"""Watches a range of keys with a prefix, similar to watch_once"""
kwargs['range_end'] = \
_increment_last_byte(_encode(key_prefix))
_increment_last_byte(key_prefix)
return self.watch_once(key_prefix, timeout=timeout, **kwargs)


Expand Down

2 comments on commit 309df0c

@bra-fsn
Copy link

Choose a reason for hiding this comment

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

Could you please release a new version with this fix?

@dims
Copy link
Owner

@dims dims commented on 309df0c Dec 17, 2017

Choose a reason for hiding this comment

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

@bra-fsn : Done! 0.2.1

Please sign in to comment.