metahook

package
v0.0.0-...-2a574e3 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2024 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MetaHook

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

*

  • MetaHook is a component to update the MetaConfiguration
  • over a controlled HTTP API *
  • It uses a updateHookMap to specify callback functions
  • for specific MetaConfig keys, those callbacks can be used
  • to live-update the configuration in the components. *
  • MetaHook launches a HTTP API over a UNIX socket on the specified location *
  • Main purpose for this API is that infrastructure controllers like juju
  • can manage the MetaConfig at runtime.

func CreateMetaHook

func CreateMetaHook(
	socketpath string,
	socketperm fs.FileMode,
	updatehooks UpdateHooks,
	config *metaconfig.MetaConfig) (*MetaHook, error)

*

  • Initialize MetaHook API

func (*MetaHook) Serve

func (m *MetaHook) Serve() error

*

  • Create unix socket / listener and start HTTP server *
  • Serve() will block execution, you can safely push it to a goroutine

type UpdateHooks

type UpdateHooks struct {
	// Hooks for string fields
	StringFieldHooks map[string]func(string, string) error
	// Hooks for bool fields
	BoolFieldHooks map[string]func(string, bool) error
	// Hooks for double fields
	DoubleFieldHooks map[string]func(string, float64) error
	// Hooks for list fields
	ListFieldHooks map[string]func(string, []string) error
}

*

  • Structure which holds function definitions for specific MetaConfig fields *
  • The hook function callback is called when the API is called to change the specified MetaConfig field. *
  • Every hook is executed synchroniously, make sure they do not use cost-intensive IO operations. *
  • Hooks are expected to bring the system into a state where it operates like
  • the field was set at application start!

Jump to

Keyboard shortcuts

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