Git Product home page Git Product logo

leto's Introduction

Leto

0. What is Leto mean?

In Greek mythology, Leto (/ˈliːtoʊ/) is a daughter of the Titans Coeus and Phoebe, the sister of Asteria.

1. What is Leto?

Leto is another reference example use of Hashicorp Raft. The API is redis protocol compatiable.

Raft is a consensus algorithm that is designed to be easy to understand. It's equivalent to Paxos in fault-tolerance and performance. The difference is that it's decomposed into relatively independent subproblems, and it cleanly addresses all major pieces needed for practical systems. We hope Raft will make consensus available to a wider audience, and that this wider audience will be able to develop a variety of higher quality consensus-based systems than are available today.

2. Why do this?

You can have better comprehension about how raft protocal works if you use it. This helps me a lot.

3. Run sample

3.1 show helps

bin/leto -h
Usage of bin/leto:
  -id string
        node id
  -join string
        join to already exist cluster
  -listen string
        server listen address (default ":5379")
  -raftbind string
        raft bus transport bind address (default ":15379")
  -raftdir string
        raft data directory (default "./")

3.2 Start first node

bin/leto -id id1 -raftdir ./id1

the first node will be listen user request and node join request in port 5379, and use port 15379 for raft transport.

3.3 Start second node

bin/leto -id id2 -raftdir ./id2 -listen ":6379" -raftbind ":16379" -join "127.0.0.1:5379"

3.4 Start third node

bin/leto -id id3 -raftdir ./id3 -listen ":7379" -raftbind ":17379" -join "127.0.0.1:5379"

3.5 Test

Requst first node

redis-cli -p 5379
127.0.0.1:5379> set a b
OK
127.0.0.1:5379> get a
b
127.0.0.1:5379>

Write to second node, data has been replicated to this node. And it will return not leader error if write to it.

redis-cli -p 6379
127.0.0.1:6379> get a
b
127.0.0.1:6379> set a b
(error) not leader
127.0.0.1:6379>

Now, we shutdown the first node, the second node voted to be leader.

redis-cli -p 6379
127.0.0.1:6379> get a
b
127.0.0.1:6379> set a b
OK
127.0.0.1:6379>

4. Support commands

  • GET
  • SET
  • DELETE
  • JOIN (communicate with peer when start node)
  • LEAVE (remove dead node from raft group)
  • PING
  • SNAPSHOT (trigger snapshot mannually)

leto's People

Contributors

yongman avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

leto's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.