container

package
v0.9.4 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2026 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInstanceNameDuplicate = errors.New("instance name already registered")
	ErrInstanceUnknown       = errors.New("no such instance registered")
)

Functions

This section is empty.

Types

type C

type C struct {
	Config        GlobalConfig
	DefaultLogger *log.Logger
	Modules       *Registry
	Lifetime      *LifetimeTracker
}
var Global *C

Global is the default instance while refactoring is in progress.

func New

func New() *C

type EarlyStopModule added in v0.9.4

type EarlyStopModule interface {
	LifetimeModule
	EarlyStop() error
}

EarlyStopModule is a LifetimeModule that needs to do some bookkeeping before new server instance starts during reload.

type GlobalConfig

type GlobalConfig struct {
	// StateDirectory contains the path to the directory that
	// should be used to store any data that should be
	// preserved between sessions.
	//
	// Value of this variable must not change after initialization
	// in cmd/maddy/main.go.
	StateDirectory string

	// RuntimeDirectory contains the path to the directory that
	// should be used to store any temporary data.
	//
	// It should be preferred over os.TempDir, which is
	// global and world-readable on most systems, while
	// RuntimeDirectory can be dedicated for maddy.
	//
	// Value of this variable must not change after initialization
	// in cmd/maddy/main.go.
	RuntimeDirectory string

	// LibexecDirectory contains the path to the directory
	// where helper binaries should be searched.
	//
	// Value of this variable must not change after initialization
	// in cmd/maddy/main.go.
	LibexecDirectory string
}

type LifetimeModule added in v0.9.4

type LifetimeModule interface {
	module.Module
	Start() error
	Stop() error
}

LifetimeModule is a stateful module that needs to have post-configuration startup and graceful shutdown functionality.

type LifetimeTracker added in v0.9.4

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

func NewLifetime added in v0.9.4

func NewLifetime(log *log.Logger) *LifetimeTracker

func (*LifetimeTracker) Add added in v0.9.4

func (lt *LifetimeTracker) Add(mod LifetimeModule)

func (*LifetimeTracker) EarlyStopAll added in v0.9.4

func (lt *LifetimeTracker) EarlyStopAll() error

func (*LifetimeTracker) ReloadAll added in v0.9.4

func (lt *LifetimeTracker) ReloadAll() error

func (*LifetimeTracker) StartAll added in v0.9.4

func (lt *LifetimeTracker) StartAll() error

StartAll calls Start for all registered LifetimeModule instances.

func (*LifetimeTracker) StopAll added in v0.9.4

func (lt *LifetimeTracker) StopAll() error

StopAll calls Stop for all registered LifetimeModule instances.

type Registry added in v0.9.4

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

func NewRegistry added in v0.9.4

func NewRegistry(log *log.Logger) *Registry

func (*Registry) AddAlias added in v0.9.4

func (r *Registry) AddAlias(instanceName string, alias string) error

func (*Registry) Get added in v0.9.4

func (r *Registry) Get(name string) (module.Module, error)

func (*Registry) NotInitialized added in v0.9.4

func (r *Registry) NotInitialized() []module.Module

func (*Registry) Register added in v0.9.4

func (r *Registry) Register(mod module.Module, lazyInit func() error) error

Register adds not-initialized (configured) module into registry.

lazyInit function will be called on first request to get the module from registry.

type ReloadModule added in v0.9.4

type ReloadModule interface {
	module.Module
	Reload() error
}

Jump to

Keyboard shortcuts

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