springcloud

package
v0.0.25 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2022 License: MIT Imports: 15 Imported by: 0

README

Package springcloud

  • Implements general config.KVStore interface. Will load config from remote spring config-server or local file.
  • Setup for remote spring config
    • Set environment SPRING_CLOUD_CONFIG_URL with remote config host:port
    • Set environment SPRING_CLOUD_CONFIG_PATHS with spring config paths, comma separate. E.g. /myapp/dev,/myapp/local
  • Setup for local file spring config
    • Set environment SPRING_CLOUD_CONFIG_URL with file://<local_machine_path>. E.g. file://var/local/myapp.yml
    • SPRING_CLOUD_CONFIG_PATHS env-var will be ignored
  • To configure autorefresh, set springcloud-config.refresh-interval (duration) in your config. E.g. springcloud-config.refresh-interval: 10s

Secret values

  • Use format {cipher}<encryptedvalues> to use encrypted values. E.g. {cipher}jalsdkjflasd43709uahlALJLdgajsdl. To create encrypted string value, use <spring_remote_host>/encrypt endpoint.
  • GCP SecretManager, use {sm}<your_sm_key> to use value from GCP secret manager. E.g. {sm}mysecret_database_password will load value from GCP secret manager for key secret_database_password. Probably need to setup GOOGLE_APPLICATION_CREDENTIALS environment variable too.

References

Documentation

Overview

Package springcloud helps interact with spring cloud remote config

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrStatusCode returned when call to springcloud remote config returns HTTP other than 2xx.
	ErrStatusCode = errors.New("springcloud: invalid status code response")
	// ErrConfigNotFound returned when profiles doesn't exists in remote config.
	ErrConfigNotFound = errors.New("springcloud: config not found at config server")
)

Functions

This section is empty.

Types

type RemoteConfig

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

RemoteConfig wraps thread-safe *viper.Viper key-values from springcloud remote-config. it also implements `config.KVStore` interface.

func NewRemoteConfig

func NewRemoteConfig(client *http.Client) *RemoteConfig

NewRemoteConfig create *RemoteConfig with given existing *http.Client.

func (*RemoteConfig) AllKeys

func (c *RemoteConfig) AllKeys() []string

AllKeys ...

func (*RemoteConfig) Get

func (c *RemoteConfig) Get(key string) interface{}

Get ...

func (*RemoteConfig) GetBool

func (c *RemoteConfig) GetBool(key string) bool

GetBool ...

func (*RemoteConfig) GetDuration

func (c *RemoteConfig) GetDuration(key string) time.Duration

GetDuration ...

func (*RemoteConfig) GetFloat64

func (c *RemoteConfig) GetFloat64(key string) float64

GetFloat64 ...

func (*RemoteConfig) GetInt

func (c *RemoteConfig) GetInt(key string) int

GetInt ...

func (*RemoteConfig) GetInt32

func (c *RemoteConfig) GetInt32(key string) int32

GetInt32 ...

func (*RemoteConfig) GetInt64

func (c *RemoteConfig) GetInt64(key string) int64

GetInt64 ...

func (*RemoteConfig) GetIntSlice

func (c *RemoteConfig) GetIntSlice(key string) []int

GetIntSlice ...

func (*RemoteConfig) GetSizeInBytes

func (c *RemoteConfig) GetSizeInBytes(key string) uint

GetSizeInBytes ...

func (*RemoteConfig) GetString

func (c *RemoteConfig) GetString(key string) string

GetString ...

func (*RemoteConfig) GetStringMap

func (c *RemoteConfig) GetStringMap(key string) map[string]interface{}

GetStringMap ...

func (*RemoteConfig) GetStringMapStringSlice

func (c *RemoteConfig) GetStringMapStringSlice(key string) map[string][]string

GetStringMapStringSlice ...

func (*RemoteConfig) GetStringSlice

func (c *RemoteConfig) GetStringSlice(key string) []string

GetStringSlice ...

func (*RemoteConfig) GetTime

func (c *RemoteConfig) GetTime(key string) time.Time

GetTime ...

func (*RemoteConfig) GetUint

func (c *RemoteConfig) GetUint(key string) uint

GetUint ...

func (*RemoteConfig) GetUint32

func (c *RemoteConfig) GetUint32(key string) uint32

GetUint32 ...

func (*RemoteConfig) GetUint64

func (c *RemoteConfig) GetUint64(key string) uint64

GetUint64 ...

func (*RemoteConfig) IsSet

func (c *RemoteConfig) IsSet(key string) bool

IsSet ...

func (*RemoteConfig) Load

func (c *RemoteConfig) Load(ctx context.Context) error

Load key-values from spring cloud config profile(s) if value `springcloud-config.refresh-interval` exists, preiodically refresh the values based on interval set.

func (*RemoteConfig) Set

func (c *RemoteConfig) Set(key string, value interface{})

Set ...

func (*RemoteConfig) ViperValue

func (c *RemoteConfig) ViperValue() viper.Viper

ViperValue ...

Jump to

Keyboard shortcuts

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