tooz/examples/partitioner.py
Julien Danjou 9ad740fa1e Add partitioner implementation
Add a new object called `Partitioner' which is based on the consistent
hashring implementation of tooz.hashring. The coordinator API allows to
create such an object and to use it to dispatch objects ownership across
several workers.

Change-Id: Iae8c861d5b6c15b714f1ec3bd7090d15dd468421
2017-01-01 19:03:40 +01:00

12 lines
316 B
Python

from tooz import coordination
coordinator = coordination.get_coordinator('zake://', b'host-1')
coordinator.start()
partitioner = coordinator.join_partitioned_group("group1")
# Returns {'host-1'}
member = partitioner.members_for_object(object())
coordinator.leave_partitioned_group(partitioner)
coordinator.stop()