Help us shape the future of Go! Take the 2026 Go Developer Survey

libprotoconf

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2023 License: MIT Imports: 22 Imported by: 6

README

.//libprotoconf

Test and coverage codecov Go Reference

Runtime configuration made easy with protocol-buffers.

Goals

Developers can define their desired configuration struct in a proto file, then get all sorts of ways to load that configuration into their software runtime:

  • Populate config from environment variables
  • Get a flag.FlagSet instance
  • Read and merge configs from global, user and workspace locations (/etc/mypackage/, $USER/.mypackage/, $(pwd)/.mypackage/)
  • Allow configuration changes dynamically
    • Reload on Signals
    • Reload on file change (inotify)
    • gRPC/rest configuration endpoints
    • key-value stores (consul, etcd, zookeeper, redis)
    • protoconf gRPC streaming agent
  • Formats:
    • JSON (.json)
    • YAML (.yaml, .yml)
    • pbtext (.pb)
    • pb binary (.data)
    • pb binary with base64 encoding (.base64, .b64)
    • jsonnet (.jsonnet)
    • toml (.toml)
    • hcl (.hcl)
    • cue (.cue)
  • Pre/Post hooks for dynamic changes
  • Debugging features
    • ShowConfig() method (available via gRPC/rest)
    • ConfigMetadata() method (available via gRPC/rest)
      • Where a specific variable was set (env/flag/which file/key value store/rpc)
      • When was the change applied to runtime
      • When was the change made (if made before the process was starting)
      • Who made the change (if data available)
    • /varz http endpoint
    • /metrics http endpoint for prometheus (with ConfigMetadata() information available)

Implementations

  • First implementation will be in Go. This implementation will also include the protoconf gRPC streaming agent, so developers of any language can use the dynamic reload features as a sidecar agent.
  • Future implementations (please vote!)
    • Rust (will probably replace Go for the agent implementation)
    • Python
    • JavaScript
    • Java
    • C++
    • Suggest other languages

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Logger logr.Logger
	// contains filtered or unexported fields
}

func NewConfig

func NewConfig(p proto.Message) *Config

func (*Config) AppendLoadDir

func (c *Config) AppendLoadDir(priority uint32, paths ...string) error

func (*Config) DebugLogger

func (c *Config) DebugLogger() logr.Logger

func (*Config) DefaultFlagSet

func (c *Config) DefaultFlagSet() *flag.FlagSet

FlagSet returns a flag.FlagSet instance for the config

func (*Config) DefaultLogger

func (c *Config) DefaultLogger() logr.Logger

func (*Config) DetectWorkspace

func (c *Config) DetectWorkspace() (string, error)

func (*Config) Environment

func (c *Config) Environment() error

func (*Config) LoadFromDefaultDirs

func (c *Config) LoadFromDefaultDirs()

func (*Config) LoadFromSystemDir

func (c *Config) LoadFromSystemDir() error

func (*Config) LoadFromUserDir

func (c *Config) LoadFromUserDir() error

func (*Config) LoadFromWorkspace

func (c *Config) LoadFromWorkspace() error

func (*Config) LoggerWithLevel

func (c *Config) LoggerWithLevel(v int) logr.Logger

func (*Config) PopulateFlagSet

func (c *Config) PopulateFlagSet(fs *flag.FlagSet)

func (*Config) SetEnvKeyPrefix

func (c *Config) SetEnvKeyPrefix(p string)

func (*Config) SetLogger

func (c *Config) SetLogger(logger logr.Logger) logr.Logger

func (*Config) Unmarshal

func (c *Config) Unmarshal(filename string, data []byte) error

func (*Config) UnmarshalBase64

func (c *Config) UnmarshalBase64(data []byte) error

func (*Config) UnmarshalBinary

func (c *Config) UnmarshalBinary(data []byte) error

func (*Config) UnmarshalJSON

func (c *Config) UnmarshalJSON(data []byte) error

func (*Config) UnmarshalJsonnet

func (c *Config) UnmarshalJsonnet(filename string, data []byte) error

func (*Config) UnmarshalText

func (c *Config) UnmarshalText(data []byte) error

func (*Config) UnmarshalToml

func (c *Config) UnmarshalToml(filename string, data []byte) error

func (*Config) UnmarshalYAML

func (c *Config) UnmarshalYAML(data []byte) error

Directories

Path Synopsis
config
v1

Jump to

Keyboard shortcuts

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