reload

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2025 License: AGPL-3.0 Imports: 4 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Register = NewRegistry()

Register holds a registry of reloadable objects

Functions

This section is empty.

Types

type ConfigWithMeta

type ConfigWithMeta struct {
	// Config to store
	Config *config.Config

	// Meta data related to this config
	Meta *util.MapStrPointer
}

ConfigWithMeta holds a pair of common.Config and optional metadata for it

type Registry

type Registry struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

Registry of reloadable objects and lists

func NewRegistry

func NewRegistry() *Registry

NewRegistry initializes and returns a reload registry

func (*Registry) GetRegisteredNames

func (r *Registry) GetRegisteredNames() []string

GetRegisteredNames returns the list of names registered

func (*Registry) GetReloadable

func (r *Registry) GetReloadable(name string) Reloadable

GetReloadable returns the reloadable object with the given name, nil if not found

func (*Registry) GetReloadableList

func (r *Registry) GetReloadableList(name string) ReloadableList

GetReloadableList returns the reloadable list with the given name, nil if not found

func (*Registry) MustRegister

func (r *Registry) MustRegister(name string, obj Reloadable)

MustRegister declares a reloadable object

func (*Registry) MustRegisterList

func (r *Registry) MustRegisterList(name string, list ReloadableList)

MustRegisterList declares a reloadable object list

func (*Registry) Register

func (r *Registry) Register(name string, obj Reloadable) error

Register declares a reloadable object

func (*Registry) RegisterList

func (r *Registry) RegisterList(name string, list ReloadableList) error

RegisterList declares a reloadable list of configurations

type Reloadable

type Reloadable interface {
	Reload(config *ConfigWithMeta) error
}

Reloadable provides a method to reload the configuration of an entity

type ReloadableFunc

type ReloadableFunc func(config *ConfigWithMeta) error

ReloadableFunc wraps a custom function in order to implement the Reloadable interface.

func (ReloadableFunc) Reload

func (fn ReloadableFunc) Reload(config *ConfigWithMeta) error

Reload calls the underlying function.

type ReloadableList

type ReloadableList interface {
	Reload(configs []*ConfigWithMeta) error
}

ReloadableList provides a method to reload the configuration of a list of entities

Jump to

Keyboard shortcuts

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