consul

package
v0.11.3 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2023 License: MPL-2.0 Imports: 13 Imported by: 0

README

Consul

The Consul plugin reads configuration values from the Consul KV store.

Components

  1. ConfigSourcer

Documentation

Overview

Package consul contains components for syncing app configuration with Consul.

Index

Constants

This section is empty.

Variables

View Source
var Options = []sdk.Option{
	sdk.WithComponents(&ConfigSourcer{}),
}

Options are the SDK options to use for instantiation for this plugin.

Functions

This section is empty.

Types

type ConfigSourcer

type ConfigSourcer struct {
	// contains filtered or unexported fields
}

func (*ConfigSourcer) Config

func (cs *ConfigSourcer) Config() (interface{}, error)

Config implements the Configurable interface

func (*ConfigSourcer) ConfigSet

func (cs *ConfigSourcer) ConfigSet(config interface{}) error

ConfigSet implements the ConfigurableNotify interface

func (*ConfigSourcer) Documentation

func (cs *ConfigSourcer) Documentation() (*docs.Documentation, error)

func (*ConfigSourcer) ReadFunc

func (cs *ConfigSourcer) ReadFunc() interface{}

ReadFunc returns the function for reading configuration.

The returned function can start a background goroutine to more efficiently watch for changes. The entrypoint will periodically call Read to check for updates.

If the configuration changes for any dynamic configuration variable, the entrypoint will call Stop followed by Read, so plugins DO NOT need to implement config diffing. Plugins may safely assume if Read is called after a Stop that the config is new, and that subsequent calls have the same config.

Read is called for ALL defined configuration variables for this source. If ANY change, Stop is called followed by Read again. Only one sourcer is active for a set of configs.

func (*ConfigSourcer) StopFunc

func (cs *ConfigSourcer) StopFunc() interface{}

StopFunc returns a function for stopping configuration sourcing. You can return nil if stopping is not necessary or supported for this sourcer.

The stop function should stop any background processes started with Read.

type ConfigSourcerConfig

type ConfigSourcerConfig struct {
	// Configuration for where to talk to Consul
	Address   string         `hcl:"address,optional"`
	Scheme    string         `hcl:"scheme,optional"`
	HTTPAuth  consulHTTPAuth `hcl:"http_auth,optional"`
	Token     string         `hcl:"token,optional"`
	TokenFile string         `hcl:"token_file,optional"`
	TLSConfig tlsConfig      `hcl:"tls,optional"`

	// Default location of KV data
	Datacenter string `hcl:"datacenter,optional"`
	Namespace  string `hcl:"namespace,optional"`
	Partition  string `hcl:"partition,optional"`
}

ConfigSourcerConfig is used to configure where to talk to Consul, and from where the KV data is to be retrieved

Jump to

Keyboard shortcuts

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