store

package
v1.19.3 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2023 License: LGPL-3.0 Imports: 3 Imported by: 0

Documentation

Overview

Package store defines the Store interface, some common types and some common functions.

Index

Constants

View Source
const (
	ConfigTypeDefault = "properties" // default format
	ConfigTypeJSON    = "json"       // JSON
	ConfigTypeYAML    = "yaml"       // YAML
	ConfigTypeYML     = "yml"        // YAML
	ConfigTypeEnv     = "env"        // environment
)
View Source
const (
	ChangeTypeAdded   = iota // configuration added
	ChangeTypeUpdated        // configuration updated
	ChangeTypeDeleted        // configuration deleted
)

Variables

This section is empty.

Functions

func ConfigType

func ConfigType(filename string) (string, error)

ConfigType uses file extension as configuration format, such as properties, xml, yml, yaml, json...

  • If extension is missing, default is `properties`
  • If extension is not supported, error is returned

Types

type ChangeType

type ChangeType int

ChangeType is the change type of configuration

type ConfigChange

type ConfigChange struct {
	Type ChangeType
	Key  string // key of the changed configuration
}

ConfigChange change of configuration

type ConfigChanges

type ConfigChanges struct {
	Config  ConfigContent
	Changes []ConfigChange
}

ConfigChanges changes of configurations

type ConfigContent

type ConfigContent struct {
	Type    string // configuration format: json, yaml, properties...
	Content []byte // configuration content
}

ConfigContent is the configuration content read from a Store object

type Store

type Store interface {
	Load() ([]ConfigContent, error)       // read configurations
	Watch(ch chan<- *ConfigChanges) error // watch configuration changes
	Unwatch()                             // stop watching
}

Store is the interface from which configurations can be read and watched

Directories

Path Synopsis
Package apollo implements Store for reading and watching configurations from Apollo.
Package apollo implements Store for reading and watching configurations from Apollo.
Package env implements a Store for reading and watching configurations from ENV.
Package env implements a Store for reading and watching configurations from ENV.
Package file implements a Store client for reading and watching configurations from local files.
Package file implements a Store client for reading and watching configurations from local files.

Jump to

Keyboard shortcuts

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