https://github.com/xincao9/configurator
微服务配置中心
https://github.com/xincao9/configurator
configuration microservice middleware
Last synced: about 1 month ago
JSON representation
微服务配置中心
- Host: GitHub
- URL: https://github.com/xincao9/configurator
- Owner: xincao9
- License: apache-2.0
- Created: 2020-06-22T16:27:21.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2023-05-05T02:27:48.000Z (about 2 years ago)
- Last Synced: 2025-03-28T02:53:28.139Z (about 2 months ago)
- Topics: configuration, microservice, middleware
- Language: Go
- Homepage:
- Size: 16.6 MB
- Stars: 12
- Watchers: 3
- Forks: 2
- Open Issues: 10
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# configurator
配置器的特点:
1. 完整的配置管理功能
2. 多环境,多业务组,多服务,多版本 的配置分类
## 安装中间件
**安装 [dkv](https://github.com/xincao9/dkv)**
```
docker pull xincao9/dkv
docker run -d -p 9090:9090 -p 6380:6380 dkv:latest
```**创建服务配置**
>接口
```
curl -X PUT -H 'content-type:application/json' 'http://localhost:9090/kv' -d '{"k":"configurator|TEST|BASE|USER-SERVICE|v1.0", "v":"{\"redis\":{\"host\":\"localhost\",\"port\":\"6379\"}}"}'
```>推荐使用 [configurator-ui](https://github.com/xincao9/configurator/tree/master/api) 系统管理配置
## 如何使用JAVA SDK
[configurator-cli](https://github.com/xincao9/configurator-cli)
## 如何使用GO SDK
**获取SDK**
```
go get github.com/xincao9/configurator
```**可选配置方式1:设置系统环境变量**
```
export env="TEST" // 环境
export group="BASE" // 业务组
export project="USER-SERVICE" // 项目
export version="v1.0" // 版本
export master="localhost:9090" // dkv 的master地址
export slaves="" // dkv 的slaves地址,host1:port1,host2:port2
```**可选配置方式2:$HOME/.env 文件进行配置**
```
env="TEST" // 环境
group="BASE" // 业务组
project="USER-SERVICE" // 项目
version="v1.0" // 版本
master="localhost:9090" // dkv 的master地址
slaves="" // dkv 的slaves地址,host1:port1,host2:port2
```**读取属性**
```
configurator.C.Get("redis.host")
configurator.C.Get("redis.port")
```**设置管理端口**
```
http.HandleFunc("/config", configurator.AllSettings)
http.ListenAndServe(":8080", nil)
``````
r := gin.Default()
r.GET("/config", func(c *gin.Context) {
c.JSON(http.StatusOK, configurator.C.AllSettings())
})
```**查看运行时的配置**
```
curl -X GET 'http://localhost:8080/config'
```**知识**
* [dkv](https://github.com/xincao9/dkv)
* [viper](https://github.com/spf13/viper)