kiel.zookeeper.shared_set

class kiel.zookeeper.shared_set.SharedSet(client, path, on_change)[source]

Bases: object

A simple “set” construct in Zookeeper with locking and change callbacks.

Used by the Zookeeper-based GroupedConsumer to represent the shared set of topic partitions divvied up among the group.

lock_path

Property representing the znode path of the shared lock.

start()[source]

Creates the set’s znode path and attaches the data-change callback.

add_items(new_items)[source]

Updates the shared set’s data with the given new items added.

If all of the given items are already present, no data is updated.

Works entirely behind a zookeeper lock to combat resource contention among sharers of the set.

remove_items(old_items)[source]

Updates the shared set’s data with the given items removed.

If none of the given items are present, no data is updated.

Works entirely behind a zookeeper lock to combat resource contention among sharers of the set.

serialize(data)[source]

Serializes the set data as a list in a JSON string.

deserialize(data)[source]

Parses a given JSON string as a list, converts to a python set.