Giter Site home page Giter Site logo

go-config-center's Introduction

Golang 配置中心

特性

  • 纯Golang实现
  • 基于Raft协议

TODO

  • 移除节点(下线)

初始化集群

启动第一个节点

go run ./cmd/main.go -id node-1 -haddr localhost:8081 -raddr localhost:9001 \
-rdir ~/data/go-config-center/node1

启动两个节点,并加入第一个节点的集群中

go run ../cmd/main.go -id node-2 -haddr localhost:8082 -raddr localhost:9002 \
-rdir ~/data/go-config-center/node2 -join localhost:8081

go run ../cmd/main.go -id node-3 -haddr localhost:8083 -raddr localhost:9003 \
-rdir ~/data/go-config-center/node3 -join localhost:8081

启动集群

初始化后,启动集群就无需join参数

go run ./cmd/main.go -id node-1 -haddr localhost:8081 -raddr localhost:9001 \
-rdir ~/data/go-config-center/node1

go run ../cmd/main.go -id node-2 -haddr localhost:8082 -raddr localhost:9002 \
-rdir ~/data/go-config-center/node2

go run ../cmd/main.go -id node-3 -haddr localhost:8083 -raddr localhost:9003 \
-rdir ~/data/go-config-center/node3

操作数据

分别在不同的节点上操作数据,根据需要会根据一致性级别自动重定向到Leader节点

添加数据

curl -X POST http://localhost:8081/key -d '{"foo": "bar"}' -L
curl -X GET http://localhost:8081/key/foo -L

删除数据

curl -X DELETE http://localhost:8081/key/foo -L

读取数据

curl -X GET http://localhost:8083/key/foo?level=stale
curl -X GET http://localhost:8082/key/foo?level=default  -L
curl -X GET http://localhost:8081/key/foo?level=consistent  -L

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.