Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
type Config struct { Etcd EtcdConfig `mapstructure:"etcd"` Path string `mapstructure:"path"` }
type EtcdConfig ¶
type EtcdSource ¶
type EtcdSource struct {
// contains filtered or unexported fields
}
func NewEtcdSource ¶
func NewEtcdSource(cfg EtcdConfig) (*EtcdSource, error)
NewEtcdSource creates a new EtcdSource instance configured with the provided EtcdConfig. It takes cfg of type EtcdConfig which includes the servers and prefix for the etcd client. It returns a pointer to EtcdSource and an error. It returns an error if no etcd key prefix is provided or if the etcd client creation fails.
func (*EtcdSource) LoadConfig ¶
func (es *EtcdSource) LoadConfig(ctx context.Context) ([]handlerfactory.Config, error)
LoadConfig loads configuration data from an etcd source. It takes a context.Context as a parameter to manage the request's lifetime. It returns a slice of handlerfactory.Config and an error. It returns an error if it fails to get the config from etcd or if it fails to unmarshal the config data.
func (*EtcdSource) PutConfig ¶
func (es *EtcdSource) PutConfig(ctx context.Context, cfg []handlerfactory.Config) error
PutConfig stores the provided configuration in the etcd key-value store. It takes a context ctx of type context.Context and a slice of handlerfactory.Config cfg. It returns an error if marshalling the config fails or if putting the config into etcd fails. The function creates a context with a timeout for each put operation.
func (*EtcdSource) Watch ¶ added in v0.4.0
func (es *EtcdSource) Watch(ctx context.Context, onUpdate func())
Watch monitors changes to keys with a specified prefix in an etcd cluster and triggers an update callback. It takes a context.Context and a callback function onUpdate which is called when changes are detected. It does not return any values. The function continues to watch for changes until the context is canceled.
type FileSource ¶
type FileSource struct {
// contains filtered or unexported fields
}
func NewFileSource ¶
func NewFileSource(path string) *FileSource
NewFileSource creates a new instance of FileSource with the given file path. It takes a single parameter path of type string which specifies the file path. It returns a pointer to a FileSource initialized with the provided path.
func (*FileSource) LoadConfig ¶
func (fs *FileSource) LoadConfig(_ context.Context) ([]handlerfactory.Config, error)
LoadConfig loads the configuration from a file or directory specified by the FileSource path. It takes a context parameter which is currently unused. It returns a slice of handlerfactory.Config and an error. It returns an error if the file or directory cannot be accessed, or if the configuration cannot be read. If the path points to a directory, it reads all configuration files within the directory. If the path points to a regular file, it reads the configuration from that file. It returns an error if the path points to an unsupported file type.