configurator

package module
v0.0.0-...-cbf984a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 18, 2020 License: Apache-2.0 Imports: 15 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

configurator

配置器的特点:

  1. 完整的配置管理功能
  2. 多环境,多业务组,多服务,多版本 的配置分类

architectures

安装中间件

安装 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 系统管理配置

如何使用JAVA SDK

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'

知识

Documentation

Index

Constants

View Source
const (
	FN  = "application"
	Ext = "json"
)

Variables

View Source
var (
	C *configurator
)
View Source
var (
	I *info
)

Functions

func AllSettings

func AllSettings(w http.ResponseWriter, _ *http.Request)

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址