config

package
v0.0.0-...-d2438c5 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2019 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Schema = config.Schema{
	"cluster.offline_threshold":      {Type: config.Int64, Default: clusterOfflineThresholdDefault(), Validator: offlineThresholdValidator},
	"core.proxy_http":                {},
	"core.proxy_https":               {},
	"core.https_allowed_headers":     {},
	"core.https_allowed_methods":     {},
	"core.https_allowed_origin":      {},
	"core.https_allowed_credentials": {Type: config.Bool},
	"discovery.https_address":        {},
	"discovery.offline_threshold":    {Type: config.Int64, Default: discoveryOfflineThresholdDefault(), Validator: offlineThresholdValidator},
}

Schema defines available server configuration keys.

Functions

This section is empty.

Types

type Config

type Config struct {
	*ReadOnlyConfig
	// contains filtered or unexported fields
}

Config holds cluster-wide configuration values.

func Load

func Load(tx Tx, schema config.Schema) (*Config, error)

Load a new Config object with the current cluster configuration values fetched from the database.

func NewConfig

func NewConfig(configMap config.Map, options ...Option) *Config

NewConfig creates a Config with sane defaults.

func (*Config) Dump

func (c *Config) Dump() (map[string]interface{}, error)

Dump current configuration keys and their values. Keys with values matching their defaults are omitted.

func (*Config) Patch

func (c *Config) Patch(patch map[string]interface{}) (map[string]string, error)

Patch changes only the configuration keys in the given map.

Return what has actually changed.

func (*Config) ReadOnly

func (c *Config) ReadOnly() *ReadOnlyConfig

ReadOnly returns the underlying readonly map

func (*Config) Replace

func (c *Config) Replace(values map[string]interface{}) (map[string]string, error)

Replace the current configuration with the given values.

Return what has actually changed.

type Option

type Option func(*options)

Option to be passed to New to customize the resulting instance.

func WithMap

func WithMap(configMap config.Map) Option

WithMap sets the configMap on the options

func WithNodeTx

func WithNodeTx(clusterTx Tx) Option

WithNodeTx sets the clusterTx on the options

type ReadOnlyConfig

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

ReadOnlyConfig only allows the reading of values from the map

func NewReadOnlyConfig

func NewReadOnlyConfig(values map[string]string, schema config.Schema) (*ReadOnlyConfig, error)

NewReadOnlyConfig creates a read only configuration with values

func (*ReadOnlyConfig) DiscoveryAddress

func (c *ReadOnlyConfig) DiscoveryAddress() (string, error)

DiscoveryAddress returns the API address for the discovery service

func (*ReadOnlyConfig) DiscoveryOfflineThreshold

func (c *ReadOnlyConfig) DiscoveryOfflineThreshold() (time.Duration, error)

DiscoveryOfflineThreshold returns the configured heartbeat threshold, i.e. the number of seconds before after which an unresponsive service node is considered offline..

func (*ReadOnlyConfig) HTTPSAllowedCredentials

func (c *ReadOnlyConfig) HTTPSAllowedCredentials() (bool, error)

HTTPSAllowedCredentials returns the relevant CORS setting.

func (*ReadOnlyConfig) HTTPSAllowedHeaders

func (c *ReadOnlyConfig) HTTPSAllowedHeaders() (string, error)

HTTPSAllowedHeaders returns the relevant CORS setting.

func (*ReadOnlyConfig) HTTPSAllowedMethods

func (c *ReadOnlyConfig) HTTPSAllowedMethods() (string, error)

HTTPSAllowedMethods returns the relevant CORS setting.

func (*ReadOnlyConfig) HTTPSAllowedOrigin

func (c *ReadOnlyConfig) HTTPSAllowedOrigin() (string, error)

HTTPSAllowedOrigin returns the relevant CORS setting.

func (*ReadOnlyConfig) OfflineThreshold

func (c *ReadOnlyConfig) OfflineThreshold() (time.Duration, error)

OfflineThreshold returns the configured heartbeat threshold, i.e. the number of seconds before after which an unresponsive node is considered offline..

func (*ReadOnlyConfig) ProxyHTTP

func (c *ReadOnlyConfig) ProxyHTTP() (string, error)

ProxyHTTP returns the configured HTTP proxy, if any.

func (*ReadOnlyConfig) ProxyHTTPS

func (c *ReadOnlyConfig) ProxyHTTPS() (string, error)

ProxyHTTPS returns the configured HTTPS proxy, if any.

type Tx

type Tx interface {

	// Config fetches all node-level config keys.
	Config() (map[string]string, error)

	// UpdateConfig updates the given node-level configuration keys in the
	// config table. Config keys set to empty values will be deleted.
	UpdateConfig(map[string]string) error
}

Tx models a single interaction with a cluster database.

Jump to

Keyboard shortcuts

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