项目作者: arriqaaq

项目描述 :
Implementation of Chord DHT(Distributed Hash Table) paper
高级语言: Go
项目地址: git://github.com/arriqaaq/chord.git
创建时间: 2018-08-28T08:37:16Z
项目社区:https://github.com/arriqaaq/chord

开源协议:MIT License

下载


Chord

[WIP]
Implementation of Chord paper

Paper

https://pdos.csail.mit.edu/papers/ton:chord/paper-ton.pdf

Example Usage

  1. package main
  2. import (
  3. "github.com/arriqaaq/chord"
  4. "github.com/arriqaaq/chord/internal"
  5. "log"
  6. "os"
  7. "os/signal"
  8. "time"
  9. )
  10. func createNode(id string, addr string, joinNode *internal.Node) (*chord.Node, error) {
  11. cnf := chord.DefaultConfig()
  12. cnf.Id = id
  13. cnf.Addr = addr
  14. cnf.Timeout = 10 * time.Millisecond
  15. cnf.MaxIdle = 100 * time.Millisecond
  16. n, err := chord.NewNode(cnf, joinNode)
  17. return n, err
  18. }
  19. func main() {
  20. joinNode := chord.NewInode("1", "0.0.0.0:8001")
  21. h, err := createNode("8", "0.0.0.0:8003", joinNode)
  22. if err != nil {
  23. log.Fatalln(err)
  24. return
  25. }
  26. c := make(chan os.Signal, 1)
  27. signal.Notify(c, os.Interrupt)
  28. <-c
  29. h.Stop()
  30. }

References

This implementation helped me a lot in designing the code base
https://github.com/r-medina/gmaj

TODO

  • Add more test cases
  • Add stats/prometheus stats