pyitc
Python bindings for the libitc library.
Table Of Contents
What Are Interval Tree Clocks?
Interval Tree Clocks (ITC) are a generalisation of the Vector Clock and Version Vector mechanisms, allowing for scalable and efficient management of a
highly dynamic number of replicas/processes in a distributed system.
See the ITC research paper from Paulo Sérgio Almeida, Carlos Baquero and Victor Fonte for more information.
Features
- Provides easy-to-use, Pythonesque bindings for the underlying C library
- Provides
__str__
methods for easy visualisation of the ITC trees - Provides bindings for the C lib's "extended API"
- Uses 64-bit event counters
Getting Started
Prerequisites
Download and install the wheels/sdist from PyPI or GitHub.
Usage Examples
Here are some usage examples:
from pyitc import Stamp, StampComparisonResult
from pyitc.extended_api import Id, Event
stamp = Stamp()
stamp.event()
stamp2 = stamp.fork()
print(stamp)
print(stamp.peek())
print(stamp2)
if stamp == stamp2:
print("yay!")
else:
print("nay")
if stamp.compare_to(stamp2) == StampComparisonResult.EQUAL:
print("yay again!")
stamp2.event()
if stamp.compare_to(stamp2) == StampComparisonResult.CONCURRENT:
print("Oh no! What should we do now?")
stamp3 = stamp2.fork()
stamp2.join(stamp3)
if not stamp3.is_valid():
print("stamp3 was joined with stamp2 and is no longer valid!")
print(stamp.id_component)
print(stamp.event_component)
stamp.event_component = Event()
stamp.id_component = Id(seed=True)
print(stamp.serialise())
print(stamp.id_component.serialise())
print(stamp.event_component.serialise())
remote_stamp = Stamp.deserialise(b'...')
remote_event = Event.deserialise(b'...')
remote_id = Id.deserialise(b'...')
Contributing
See CONTRIBUTING.md.
Reporting Vulnerabilities
:warning: NEVER open public issues or pull requests to report or fix security vulnerabilities.
See the Security Policy.