Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
forked from zhebrak/raftos

Asynchronous replication framework for distributed Python projects

License

Notifications You must be signed in to change notification settings

lu-algorithm/raftos

Repository files navigation

raftos

Build Status PyPI version

Asynchronous replication framework based on Raft Algorithm for fault-tolerant distributed systems.

Install

pip install raftos

Register nodes on every server

import raftos
loop.create_task(
 raftos.register(
 # node running on this machine
 '127.0.0.1:8000',
 # other servers
 cluster=[
 '127.0.0.1:8001',
 '127.0.0.1:8002'
 ]
 )
)
loop.run_forever()

Data replication

counter = raftos.Replicated(name='counter')
data = raftos.ReplicatedDict(name='data')
# value on a leader gets replicated to all followers
await counter.set(42)
await data.update({
 'id': 337,
 'data': {
 'amount': 20000,
 'created_at': '7/11/16 18:45'
 }
})

In case you only need consensus algorithm with leader election

await raftos.wait_until_leader(current_node)

or

if raftos.get_leader() == current_node:
 # make request or respond to a client

or

raftos.configure({
 'on_leader': start,
 'on_follower': stop
})

Whenever the leader falls, someone takes its place.

Paper & Video

About

Asynchronous replication framework for distributed Python projects

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%

AltStyle によって変換されたページ (->オリジナル) /