Skip to content

Conversation

@BrianEaton1
Copy link
Contributor

@BrianEaton1 BrianEaton1 commented May 2, 2019

this patch allows java clients using curator's SharedCount recipe
and python clients using kazoo's Counter recipe to read and
write from the same path without receiving type errors.

example use:
counter = zk.Counter("/curator", support_curator=True)
counter += 2
counter -= 1
counter.value == 1
counter.pre_value == 2
counter.post_value == 1

Closes #558

this patch allows java clients using curator's SharedCount recipe
and python clients using kazoo's Counter recipe to read and
write from the same path without receiving type errors.

example use:

counter = zk.Counter("/curator", support_curator_shared_count=True)
counter += 2
counter -= 1
counter.value == 1
counter.pre_value == 2
counter.post_value == 1

Closes python-zk#558
self.assertRaises(TypeError, counter.__add__, 2.1)
self.assertRaises(TypeError, counter.__add__, b"a")
with self.assertRaises(TypeError):
counter = self._makeOne(default=0.0, support_curator_shared_count=True)

Choose a reason for hiding this comment

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

line too long (83 > 79 characters)

counter - 1
eq_(counter.value, -1)
counter += 1
counter += 2147483647

Choose a reason for hiding this comment

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

trailing whitespace

self.pre_value = None
self.post_value = None
if self.support_curator_shared_count and not isinstance(self.default, int):
raise TypeError('when support_curator_shared_count is enabled the default type must be an int')

Choose a reason for hiding this comment

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

line too long (107 > 79 characters)

self._ensured_path = False
self.pre_value = None
self.post_value = None
if self.support_curator_shared_count and not isinstance(self.default, int):

Choose a reason for hiding this comment

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

line too long (83 > 79 characters)

:param path: The counter path to use.
:param default: The default value.
:param default: The default value to use for new counter paths.
:param support_curator_shared_count: Enable if support for curator's SharedCount recipe is desired.

Choose a reason for hiding this comment

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

line too long (107 > 79 characters)

either kazoo's counter recipe or curator's SharedCount recipe, you will
need to enable the support_curator_shared_count flag. This flag limits
support to integers only and does not use ascii encoding as described
above.

Choose a reason for hiding this comment

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

trailing whitespace

If you would like to support clients updating the same znode path using
either kazoo's counter recipe or curator's SharedCount recipe, you will
need to enable the support_curator_shared_count flag. This flag limits
support to integers only and does not use ascii encoding as described

Choose a reason for hiding this comment

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

trailing whitespace

If you would like to support clients updating the same znode path using
either kazoo's counter recipe or curator's SharedCount recipe, you will
need to enable the support_curator_shared_count flag. This flag limits

Choose a reason for hiding this comment

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

trailing whitespace

such other data types might be used for the counter value.
If you would like to support clients updating the same znode path using
either kazoo's counter recipe or curator's SharedCount recipe, you will

Choose a reason for hiding this comment

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

trailing whitespace

`type(counter.default)(value)` both using an ascii encoding. As
such other data types might be used for the counter value.
If you would like to support clients updating the same znode path using

Choose a reason for hiding this comment

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

trailing whitespace

:param path: The counter path to use.
:param default: The default value.
:param default: The default value to use for new counter paths.
:param support_curator: Enable if support for curator's SharedCount

Choose a reason for hiding this comment

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

trailing whitespace

@StephenSorriaux
Copy link
Member

Hi @BrianEaton1,

Thanks a lot for your time to produce this PR. I will review it as soon as possible.

Copy link
Member

@StephenSorriaux StephenSorriaux left a comment

Choose a reason for hiding this comment

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

Thanks for this PR!

@StephenSorriaux StephenSorriaux merged commit 88b657a into python-zk:master May 7, 2019
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.

Allow counter recipe to work seamlessly with curator's SharedCount recipe

3 participants