All Projects → go-chassis → Go Archaius

go-chassis / Go Archaius

Licence: apache-2.0
a dynamic configuration framework used in distributed system

Programming Languages

go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to Go Archaius

Go Chassis
a microservice framework for rapid development of micro services in Go with rich eco-system
Stars: ✭ 2,428 (+1725.56%)
Mutual labels:  microservice, distributed-systems
Microservices Connector
Inter-Service communication framework, support for microservice architecture and distributed system
Stars: ✭ 17 (-87.22%)
Mutual labels:  microservice, distributed-systems
core
Microservice abstract class
Stars: ✭ 37 (-72.18%)
Mutual labels:  distributed-systems, microservice
Moleculer
🚀 Progressive microservices framework for Node.js
Stars: ✭ 4,845 (+3542.86%)
Mutual labels:  microservice, distributed-systems
Jupiter
Jupiter是一款性能非常不错的, 轻量级的分布式服务框架
Stars: ✭ 1,372 (+931.58%)
Mutual labels:  microservice, distributed-systems
Log Sys
A distributed log system which is based on spring cloud & docker
Stars: ✭ 161 (+21.05%)
Mutual labels:  microservice, distributed-systems
Hemera
🔬 Writing reliable & fault-tolerant microservices in Node.js https://hemerajs.github.io/hemera/
Stars: ✭ 773 (+481.2%)
Mutual labels:  microservice, distributed-systems
Go Grpc
A simpler grpc framework
Stars: ✭ 133 (+0%)
Mutual labels:  microservice, distributed-systems
Marblerun
Marblerun is the service mesh for confidential computing. Deploy, scale, and verify your confidential microservices on vanilla Kubernetes. 100% Go, 100% cloud native, 100% confidential
Stars: ✭ 98 (-26.32%)
Mutual labels:  microservice, distributed-systems
Microdot
Microdot: An open source .NET microservices framework
Stars: ✭ 1,222 (+818.8%)
Mutual labels:  microservice, distributed-systems
Awesome Microservices Netcore
💎 A collection of awesome training series, articles, videos, books, courses, sample projects, and tools for Microservices in .NET Core
Stars: ✭ 865 (+550.38%)
Mutual labels:  microservice, distributed-systems
Genie
Distributed Big Data Orchestration Service
Stars: ✭ 1,544 (+1060.9%)
Mutual labels:  microservice, distributed-systems
Dotnet Istanbul Microservices Demo
This is the demo application that i created for my talk 'Microservice Architecture & Implementation with Asp.Net Core' at Dotnet İstanbul Meetup Group.
Stars: ✭ 109 (-18.05%)
Mutual labels:  microservice, distributed-systems
Lottor
distributed transaction service based on reliable msg,基于可靠消息的柔性分布式事务实现方案。
Stars: ✭ 122 (-8.27%)
Mutual labels:  microservice, distributed-systems
Pyro5
Pyro 5 - Python remote objects for modern python versions
Stars: ✭ 123 (-7.52%)
Mutual labels:  distributed-systems
Mix
☄️ PHP CLI mode development framework, supports Swoole, WorkerMan, FPM, CLI-Server / PHP 命令行模式开发框架,支持 Swoole、WorkerMan、FPM、CLI-Server
Stars: ✭ 1,753 (+1218.05%)
Mutual labels:  microservice
Tarsframework
Tars Basic service framework
Stars: ✭ 122 (-8.27%)
Mutual labels:  microservice
Microservice Recruit
基于微服务架构实现的智能招聘系统(用于毕业设计)-前端地址:https://github.com/Clairezyw/recruit
Stars: ✭ 124 (-6.77%)
Mutual labels:  microservice
Grpc Nebula
微服务治理框架简介
Stars: ✭ 132 (-0.75%)
Mutual labels:  microservice
Panic Server
Testing for collaborative apps and tools
Stars: ✭ 128 (-3.76%)
Mutual labels:  distributed-systems

go-archaius

Build Status Coverage Status HitCount goproxy.cn

This is a light weight configuration management framework which helps to manage configurations in distributed system

The main objective of go archaius is to pull and sync the configuration from multiple sources

Why use go-archaius

it is hard to manage configurations in a distributed system. archaius is able to put all configuration in distributed system together and manage them. To make it simple to get the exact config you want in distributed system. It also keeps watching configuration changes, and fire change event if value changes. so that you can easily implement a service which has hot-reconfiguration features. when you need to change configurations, your service has zero-down time.

Conceptions

Sources

Go-archaius can manage multiple sources at the same time. Each source can holds same or different key value pairs. go-archaius keeps all the sources marked with their precedence, and merge key value based on precedence. in case if two sources have same key then key with higher precedence will be selected, and you can use archaius API to get its value

Here is the precedence list:

0: remote source - pull remote config server data into local

1: Memory source - after init, you can set key value in runtime.

2: Command Line source - read the command lines arguments, while starting the process.

3: Environment Variable source - read configuration in Environment variable.

4: Files source - read files content and convert it into key values based on the FileHandler you define

Dimension

It only works if you enable remote source, as remote server, it could has a lot of same key but value is different. so we use dimension to identify kv. you can also get kv in other dimension by add new dimension

Event management

You can register event listener by key(exactly match or pattern match) to watch value change.

File Handler

It works in File source, it decide how to convert your file to key value pairs. check FileHandler, currently we have 2 file handler implementation

archaius API

developer usually only use API to interact with archaius, check API.

To init archaius

archaius.Init()

when you init archaius you can decide what kind of source should be enable, required file slice was given, archaius checks file existing and add them into file source, if not exist, init fails, below example also enables env and mem sources.

	err := archaius.Init(
		archaius.WithRequiredFiles([]string{filename1}),
		archaius.WithOptionalFiles([]string{filename2}),
		archaius.WithENVSource(),
		archaius.WithMemorySource())

Put value into archaius

Notice, key value will be only put into memory source, it could be overwritten by remote config as the precedence list

archaius.Set("interval", 30)
archaius.Set("ttl", "30s")
archaius.Set("enable", false)

Read config files

if you have a yaml config

some:
  config: 1
ttl: 30s
service:
  name: ${NAME||go-archaius}
  addr: ${IP||127.0.0.1}:${PORT||80} 

after adding file

archaius.AddFile("/etc/component/xxx.yaml")

you can get value

ttl := archaius.GetString("ttl", "60s")
i := archaius.GetInt("some.config", "")
serviceName := archaius.GetString("service.name", "")
serviceAddr := archaius.GetString("service.addr", "")

note:

  1. For service.name config with value of ${NAME||go-archaius} is support env syntax. If environment variable ${NAME} isn't setting, return default value go-archaius. It's setted, will get real environment variable value.
  2. For service.addr config is support "expand syntax". If environment variable ${IP} or ${PORT} is setted, will get env config. eg: export IP=0.0.0.0 PORT=443 , archaius.GetString("service.addr", "") will return 0.0.0.0:443 .

if you want to read some.config from env you can run

export some_config=xxxx

then you can read it by below code

i := archaius.GetInt("some.config", "")

by default archaius only support yaml files, but you can extend file handler to handle file in other format, for example we only consider file name as a key, content is the value.

archaius.AddFile("xxx.txt", archaius.WithFileHandler(util.FileHandler(util.UseFileNameAsKeyContentAsValue))

you can get value

v := archaius.GetString("/etc/component/xxx.txt", "")

Enable remote source

If you want to use one remote source, you must import the corresponding package of the source in your code.

import _ "github.com/go-chassis/go-archaius/source/remote/kie"

set remote info to init remote source

	ri := &archaius.RemoteInfo{
	//input your remote source config
	}
	//manage local and remote key value at same time
	err := archaius.Init(
		archaius.WithRequiredFiles([]string{filename1}),
		archaius.WithOptionalFiles([]string{filename2}),
		archaius.WithRemoteSource(archaius.KieSource, ri),
	)

Supported distributed configuration management service:

name import description
kie github.com/go-chassis/go-archaius/source/remote/kie ServiceComb-Kie is a config server which manage configurations in a distributed system. It is also a micro service in ServiceComb ecosystem and developed by go-chassis we call it ServiceComb Native application. https://kie.readthedocs.io
config-center github.com/go-chassis/go-archaius/source/remote/configcenter huawei cloud CSE config center https://www.huaweicloud.com/product/cse.html
apollo github.com/go-chassis/go-archaius/source/apollo A reliable configuration management system https://github.com/ctripcorp/apollo

Example: Manage local configurations

Complete example

Example: Manage key value change events

Complete example

Example: Manage remote source configurations

Complete example

Example: Manage module change events

Sometimes, we may want to handle multiple key value changes as a module, which means that the different key in the module has some relation with each other. Once such keys have changed, we expect to handle the changes as a whole instead of one by one. Module events help us to handle this case.

Complete example

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].