Code Monkey home page Code Monkey logo

xconf's Introduction

XConf 分布式配置中心

Github Actions Go Report Card GoDoc LICENSE Code Size

XConf 基于 go-micro 构建的分布式配置中心,提供配置的管理与发布、实时推送.

使用本项目的公司

特点

  • 修改实时推送
  • 高效读取配置
  • 支持界面管理、配置导入导出
  • 支持服务器agent进程,程序无感知接入
  • 安装部署方便,简单

服务架构

image

  • App
    • Cluster 集群 (A区,B区,C区)
      • Namespace 空间(可理解为一个个配置文件:db.json,db.toml)
        • Value 配置内容

目录结构

.
├── LICENSE
├── README.md
├── admin-api   // 配置管理 api 服务
├── agent-api   // 配置获取,推送服务
├── client      // micro config 客户端插件
├── config-srv  // 配置管理服务
├── dashboard   // 前端UI
├── doc
├── go.mod
├── go.sum
├── micro       // micro api 网关
└── proto

前端 UI

线上 demo - http://xconf.mogutou.xyz/admin/ui

image

image

image

image

快速开始

  • 依赖

    MySQL XConf 底层存储使用 mysql 数据库

    CREATE DATABASE xconf

    root:12345@(127.0.0.1:3306)/xconf?charset=utf8&parseTime=true&loc=Local

  • docker 快速启动 all in one

    所有服务打包到一个容器中,仅仅作为快速预览使用,不可作为生产使用。

    docker pull xuxu123/xconf-all:latest
    docker run --name xconf -it --rm -p 8080:8080 -e BROADCAST=broker -e DATABASE_URL="root:12345@(IP地址:3306)/xconf?charset=utf8&parseTime=true&loc=Local" xuxu123/xconf-all

    UI: http://127.0.0.1:8080/admin/ui

  • agent

    agent 负责实时获取指定 应用/集群 下的所有配置文件到指定文件夹中

    NAME:
       agent - XConf agent client
    
    USAGE:
       main [global options] command [command options] [arguments...]
    
    VERSION:
       0.0.1
    
    COMMANDS:
         help, h  Shows a list of commands or help for one command
    
    GLOBAL OPTIONS:
       --url value, -u value      base url (default: "127.0.0.1:8080") [$XCONF_BASE_URL]
       --app value, -a value      app name [$XCONF_APP_NAME]
       --cluster value, -c value  cluster name [$XCONF_CLUSTER_NAME]
       --dir value, -d value      directory (default: "/tmp") [$XCONF_DIR]
       --help, -h                 show help
       --version, -v              print the version
    
    
    docker run --name agent -v /tmp/docker-xconf:/tmp  -d  xuxu123/agent  -u http://xconf.mogutou.xyz -a test -c dev -d /tmp

客户端

  • Golang pkg/client/example

    git clone https://github.com/micro-in-cn/XConf.git
    cd XConf/pkg/client/example
    go run main.go 

    客户端支持读取配置,实时获取配置更新(页面上"发布"操作才能触发配置推送,"保存"操作仅是保存配置)

部署与构建

感谢

XConf 参考了 Apollo 在业界成熟的设计方案。

xconf's People

Contributors

allenxuxu avatar asim avatar chaojuwang avatar hb-chen avatar wenyxu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

xconf's Issues

支持配置类型的格式校验

可以支持一些常规的json、yaml等的格式校验,考虑通用可以不做强制,而给个warning提示,前端作业可以。
如果能再支持些正则之类的自定义规则就更好了^_^

提几个问题

  1. 分布式配置的引擎是什么?Eureca? Nacos? Zk?Etcd ? 如果是zk可以看看小米的shepher的架构。纯mysql可能要明确一下能力边界
    2.阿波罗那套配置模型是否完全合理?
    3.最好找个专业前端参与。可以参考小米shepher的配置编辑器实现
    4.相比apollo 的优势在哪?golang项目部署更轻量级?apollo自身服务的发现等问题怎么解决?
    5.找到种子用户,不然做着做着就没兴趣做下去了。哪怕强制在自己的公司推动使用也行

npm run dev error!

npm run dev
npm ERR! missing script: dev

npm ERR! A complete log of this run can be found in:
verbose stack Error: missing script: dev

进入package.json里面:
"scripts": {
"start": "react-app-rewired start",
"build": "react-app-rewired build",
"build:analyzer": "REACT_APP_NODE_ENV=analyzer react-app-rewired build",
"test": "react-app-rewired test",
"lint:fix": "eslint --fix --ext .js --ext .jsx --ext .ts --ext .tsx src",
"generate": "bash ./generate.sh"
},
没有dev选项

source watch error: "...": EOF

还是以前的问题,始终没有解决

2020-06-29 11:33:13  level=info [XConf] source watch error : %s (will sleep 1 second)[Get "http://***/agent/api/v1/watch?appName=micro&clusterName=dev&namespaceName=user_srv&updatedAt=": EOF]

source watcher报错

Source Watch 报错;不支持较长的配置文件

  1. 成功初始化配置源后,watch时报错
    2020-04-10 18:35:15 level=info [XConf] source watch error : %s (will sleep 1 second)[Get "http://***/agent/api/v1/watch?appName=micro&clusterName=dev&namespaceName=jwt&updatedAt=": EOF]

  2. 不支持拉取较长的配置文件(70行不到?)
    curl 结果如下
    {"Error":"The entry size is larger than 1/1024 of cache size"}
    检查数据库,发现配置写进去了,agent拉取的时候出错?

建议指定srv和api的端口,或可以通过参数,环境变量等更改

准备将这套中心往现有的micro架子里面迁移,整套架子是部署到k8s上的,原本是打算每个模块一个pod然后暴露出端口供外部通信,但是目前的srv和api都没有指定端口,所以只能将所有的服务连带micro gateway一起打包放进了一个pod,这样就稍微有一点臃肿,违背了微服务的初衷了
希望可以每个服务独立指定端口和对应的名字,以便整合进原有的go-micro框架中
ps. 初学k8s,可能有更好的解决方案我才疏学浅不知道==

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.