config

package
v0.0.0-...-68fa315 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2017 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Config client for Spring Cloud Configuration server.

Index

Constants

View Source
const (
	// EnvConfigProfile holds the name of the environment variable (CONFIG_PROFILE)
	// which is used during runtime lookups
	EnvConfigProfile = "CONFIG_PROFILE"
	// The configuration server URI environment variable (CONFIG_SERVER_URI)
	// ex. http://host:8888
	EnvConfigServerURI = "CONFIG_SERVER_URI"
	// UriDefault is the default URI to the configuration server
	UriDefault = "http://localhost:8888"
	// ProfileDefault is the default profile
	ProfileDefault = "default"
	// LabelDefault is the initial SCM branch
	LabelDefault = "master"
)

Variables

View Source
var (
	NameNotDeclaredErr = errors.New("Name must be declared")
	FileNotDeclaredErr = errors.New("Filename must have a value")
)

Functions

This section is empty.

Types

type Bootstrap

type Bootstrap struct {

	// The URI of the remote server (default http://localhost:8888).
	URI string `json:"uri"`

	// Context is used as the base URI an optional /refresh endpoint which can by
	// exposed to update an anonynmous function when configuration changes
	Context string `json:"context"`

	// Profile represents the default to use when fetching remote configuration (comma-separated).
	// Default is "default".
	//
	// Note: During runtime the config client looks for the presence of an environment
	// variable called CONFIG_PROFILE.  If this is defined it overwrites this value.
	Profile string `json:"profile"`

	// Name of application used to fetch remote properties.
	Name string `json:"name"`

	// Label name to use to pull remote configuration properties. The default is set
	// on the server (generally "master" for a git based server).
	Label string `json:"label"`

	// The username to use (HTTP Basic) when contacting the remote server.
	Username string `json:"username,omitempty"`

	// The password to use (HTTP Basic) when contacting the remote server.
	Password string `json:"password,omitempty"`
}

Bootstrap is the properties needed to fetch a remote configuration from spring cloud configuration server.

func (*Bootstrap) PopulateDefaultsIfEmpty

func (b *Bootstrap) PopulateDefaultsIfEmpty()

type ConfigClient

type ConfigClient interface {
	// Fetch queries the remote configuration service and populates the
	// target value
	Fetch(target interface{}) error

	// FetchWithSubstitution fetches a remote config, substitutes environment variables
	// and writes it to the target
	FetchWithSubstitution(target interface{}) error

	// Fetch queries the remote configuration service and populates
	// a map of kv strings.   This call flattens hierarchical values
	// into flattened form.  Example:  datasource.mysql.user
	FetchAsMap() (map[string]string, error)

	// Fetch queries the remote configuration service and returns
	// the result as a JSON string
	FetchAsJSON() (string, error)

	// Fetch queries the remote configuration service and returns
	// the result as a YAML string
	FetchAsYAML() (string, error)

	// Fetch queries the remote configuration service and returns
	// the result as a Properties string
	FetchAsProperties() (string, error)

	// Bootstrap returns a reference to the current bootstrap settings
	Bootstrap() *Bootstrap
}

func LoadFromFile

func LoadFromFile(filename string) (ConfigClient, error)

func New

func New(b Bootstrap) (ConfigClient, error)

New creates a new ConfigClient based on b Bootstrap Error will be thrown if Name is not set

Jump to

Keyboard shortcuts

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