All Projects → beatlabs → Harvester

beatlabs / Harvester

Licence: apache-2.0
Harvest configuration, watch and notify subscriber

Programming Languages

go
31211 projects - #10 most used programming language
golang
3204 projects

Projects that are alternatives of or similar to Harvester

Apollo
Apollo is a reliable configuration management system suitable for microservice configuration management scenarios.
Stars: ✭ 26,052 (+33300%)
Mutual labels:  configuration-management
System
Development repository for the "system" Chef cookbook
Stars: ✭ 21 (-73.08%)
Mutual labels:  configuration-management
Stonic
Stonic Application
Stars: ✭ 61 (-21.79%)
Mutual labels:  configuration-management
Conf
Simple config handling for your app or module
Stars: ✭ 707 (+806.41%)
Mutual labels:  configuration-management
Config Rs
⚙️ Layered configuration system for Rust applications (with strong support for 12-factor applications).
Stars: ✭ 915 (+1073.08%)
Mutual labels:  configuration-management
Chef Plugin
This is jenkins plugin to run chef-client on remote host
Stars: ✭ 38 (-51.28%)
Mutual labels:  configuration-management
Ini Parser
Read/Write an INI file the easy way!
Stars: ✭ 643 (+724.36%)
Mutual labels:  configuration-management
Decode Config
Backup/restore and decode configuration tool for Tasmota
Stars: ✭ 73 (-6.41%)
Mutual labels:  configuration-management
Bash Toolkit
Este proyecto esá destinado a ayudar a los sysadmin
Stars: ✭ 13 (-83.33%)
Mutual labels:  configuration-management
Node No Config
Config and resource loader
Stars: ✭ 45 (-42.31%)
Mutual labels:  configuration-management
Opsmop
DISCONTINUED: permanent copy of fork lives at github.com/mpdehaan/opsmop
Stars: ✭ 725 (+829.49%)
Mutual labels:  configuration-management
Strictyaml
Type-safe YAML parser and validator.
Stars: ✭ 836 (+971.79%)
Mutual labels:  configuration-management
Yaconf
A PHP Persistent Configurations Container
Stars: ✭ 1,017 (+1203.85%)
Mutual labels:  configuration-management
Yacs
YACS -- Yet Another Configuration System
Stars: ✭ 705 (+803.85%)
Mutual labels:  configuration-management
Pyinfra
pyinfra automates infrastructure super fast at massive scale. It can be used for ad-hoc command execution, service deployment, configuration management and more.
Stars: ✭ 1,168 (+1397.44%)
Mutual labels:  configuration-management
Spring Cloud Config Admin
Spring Cloud Config的综合管理后台(简称:SCCA)
Stars: ✭ 645 (+726.92%)
Mutual labels:  configuration-management
Configuration
Library for setting values to structs' fields from env, flags, files or default tag
Stars: ✭ 37 (-52.56%)
Mutual labels:  configuration-management
Gin Config
Gin provides a lightweight configuration framework for Python
Stars: ✭ 1,189 (+1424.36%)
Mutual labels:  configuration-management
Poet
Lets you split your ssh_config into separate files
Stars: ✭ 72 (-7.69%)
Mutual labels:  configuration-management
Kapo
Wrap any command in a status socket
Stars: ✭ 45 (-42.31%)
Mutual labels:  configuration-management

Harvester Running CI Coverage Status Go Report Card GoDoc GitHub release

Harvester is a configuration library which helps setting up and monitoring configuration values in order to dynamically reconfigure your application.

Configuration can be obtained from the following sources:

  • Seed values, are hard-coded values into your configuration struct
  • Environment values, are obtained from the environment
  • Flag values, are obtained from CLI flags with the form -flag=value
  • File internals in local storage. Only text files are supported, don't use it for binary.
  • Consul, which is used to get initial values and to monitor them for changes

The order is applied as it is listed above. Consul seeder and monitor are optional and will be used only if Harvester is created with the above components.

Harvester expects a go structure with tags which defines one or more of the above like the following:

type Config struct {
    IndexName      sync.String          `seed:"customers-v1"`
    CacheRetention sync.Int64           `seed:"86400" env:"ENV_CACHE_RETENTION_SECONDS"`
    LogLevel       sync.String          `seed:"DEBUG" flag:"loglevel"`
    Signature      sync.String          `file:"signature.txt"`
    Sandbox        sync.Bool            `seed:"true" env:"ENV_SANDBOX" consul:"/config/sandbox-mode"`
    AccessToken    sync.Secret          `seed:"defaultaccesstoken" env:"ENV_ACCESS_TOKEN" consul:"/config/access-token"`
    WorkDuration   sync.TimeDuration    `seed:"1s" env:"ENV_WORK_DURATION" consul:"/config/work-duration"`
}

The above defines the following fields:

  • IndexName, which will be seeded with the value customers-v1
  • CacheRetention, which will be seeded with the value 18, and if exists, overridden with whatever value the env var ENV_CACHE_RETENTION_SECONDS holds
  • LogLevel, which will be seeded with the value DEBUG, and if exists, overridden with whatever value the flag loglevel holds
  • Sandbox, which will be seeded with the value true, and if exists, overridden with whatever value the env var ENV_SANDBOX holds and then from consul if the consul seeder and/or watcher are provided.
  • WorkDuration, which will be seeded with the value 1s, and if exists, overridden with whatever value the env var ENV_WORK_DURATION holds and then from consul if the consul seeder and/or watcher are provided.

The fields have to be one of the types that the sync package supports in order to allow concurrent read and write to the fields. The following types are supported:

  • sync.String, allows for concurrent string manipulation
  • sync.Int64, allows for concurrent int64 manipulation
  • sync.Float64, allows for concurrent float64 manipulation
  • sync.Bool, allows for concurrent bool manipulation
  • sync.Secret, allows for concurrent secret manipulation. Secrets can only be strings
  • sync.TimeDuration, allows for concurrent time.duration manipulation.

For sensitive configuration (passwords, tokens, etc.) that shouldn't be printed in log, you can use the Secret flavor of sync types. If one of these is selected, then at harvester log instead of the real value the text *** will be displayed.

Harvester has a seeding phase and an optional monitoring phase.

Seeding phase

  • Apply the seed tag value, if present
  • Apply the value contained in the env var, if present
  • Apply the value contained in the file, if present
  • Apply the value returned from Consul, if present and harvester is setup to seed from consul
  • Apply the value contained in the CLI flags, if present

Conditions where seeding fails:

  • If at the end of the seeding phase one or more fields have not been seeded
  • If the seed value is invalid

Seeder

Harvester allows the creation of custom getters which are used by the seeder and implement the following interface:

type Getter interface {
    Get(key string) (string, error)
}

Seed and env tags are supported by default, the Consul getter has to be setup when creating a Harvester with the builder.

Monitoring phase (Consul only)

  • Monitor a key and apply if tag key matches
  • Monitor a key-prefix and apply if tag key matches

Monitor

Harvester allows for dynamically changing the config value by monitoring a source. The following sources are available:

  • Consul, which supports monitoring for keys and key-prefixes.

This feature have to be setup when creating a Harvester with the builder.

Builder

The Harvester builder pattern is used to create a Harvester instance. The builder supports setting up:

  • Consul seed, for setting up seeding from Consul
  • Consul monitor, for setting up monitoring from Consul
    h, err := New(&cfg).
                WithConsulSeed("address", "dc", "token").
                WithConsulMonitor("address", "dc", "token").
                Create()

The above snippet set's up a Harvester instance with consul seed and monitor.

Notification support

In order to be able to monitor the changes in the configuration we provide a way to notify when a change is happening via the builder.

    h, err := harvester.New(&cfg).WithNotification(chNotify).Create()
    ...

Consul

Consul has support for versioning (ModifyIndex) which allows us to change the value only if the version is higher than the one currently.

Examples

Head over to examples readme on how to use harvester

How to Contribute

See Contribution Guidelines.

Code of conduct

Please note that this project is released with a Contributor Code of Conduct. By participating in this project and its community you agree to abide by those terms.

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].