https://github.com/navono/go-consul-redis
A demo for consul based golang
https://github.com/navono/go-consul-redis
consul goalng golang-examples redis-client
Last synced: 8 months ago
JSON representation
A demo for consul based golang
- Host: GitHub
- URL: https://github.com/navono/go-consul-redis
- Owner: navono
- License: mit
- Created: 2018-08-22T08:20:24.000Z (almost 8 years ago)
- Default Branch: prometheus
- Last Pushed: 2018-08-23T02:18:20.000Z (almost 8 years ago)
- Last Synced: 2025-03-11T18:54:58.418Z (over 1 year ago)
- Topics: consul, goalng, golang-examples, redis-client
- Language: Go
- Size: 396 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# go-consul
一个基于`Golang`的`Consul`的示例
# dep
`Consul`和`Redi`服务均运行在一台IP为`192.168.56.101`的虚拟机中。在虚拟机中运行:
1. 启动 `Consul`
> consul agent -dev -client="0.0.0.0"
2. 启动 `Redis`
修改`redis.conf`,开放IP和增加登录密码
> sudo systemctl start redis
3. 启动本程序
> go run .\main.go -addrs '192.168.56.101:6379' -port 8888 -ttl '5s'
# verify
在`Redis`中增加值:
> set test 1234
获取值:
> curl http://localhost:8888/test
# reference
[blog](https://alex.dzyoba.com/blog/go-prometheus-service/)