consulloader

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Loader

type Loader struct {
	QueryOptions api.QueryOptions
	WriteOptions api.WriteOptions

	// Decode for consul file to interface{}
	//  - default is yaml decoder
	Decode func(r io.Reader, to interface{}) error
	// contains filtered or unexported fields
}

func New

func New(opts ...Option) *Loader

func (*Loader) Client

func (l *Loader) Client() *api.Client

func (*Loader) Delete

func (l *Loader) Delete(ctx context.Context, key string) error

func (*Loader) DynamicValue

func (l *Loader) DynamicValue(ctx context.Context, wg *sync.WaitGroup, key string) (<-chan []byte, func(), error)

DynamicValue return a channel for getting latest value of key. This function will start a goroutine for watching key. The caller should call stop function when it is no longer needed.

func (*Loader) Load

func (l *Loader) Load(ctx context.Context, key string) ([]byte, error)

func (*Loader) LoadChu

func (l *Loader) LoadChu(ctx context.Context, to any, opts ...loader.Option) error

func (*Loader) Set

func (l *Loader) Set(ctx context.Context, key string, value []byte) error

func (*Loader) SetClient

func (l *Loader) SetClient(c *api.Client)

type Option

type Option func(*option)

func WithDecode

func WithDecode(d func(r io.Reader, to interface{}) error) Option

WithDecode sets the decoder for the consul loader.

  • default is yaml decoder

Jump to

Keyboard shortcuts

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