{"modulePath":"github.com/foxcpp/maddy","version":"v0.9.8","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package container\n\n## Variables\n\n```go\nvar (\n\tErrInstanceNameDuplicate = errors.New(\"instance name already registered\")\n\tErrInstanceUnknown       = errors.New(\"no such instance registered\")\n)\n```\n\n## Types\n\n```go\ntype C struct {\n\tConfig        GlobalConfig\n\tDefaultLogger *log.Logger\n\tExtResolver   *dns.ExtResolver\n\tModules       *Registry\n\tLifetime      *LifetimeTracker\n}\n```\n\n```go\nvar Global *C\n```\nGlobal is the default instance while refactoring is in progress.\n\n```go\nfunc New() *C\n```\n\n```go\ntype EarlyStopModule interface {\n\tLifetimeModule\n\tEarlyStop() error\n}\n```\nEarlyStopModule is a LifetimeModule that needs to do some bookkeeping before new server instance starts during reload.\n\n```go\ntype GlobalConfig struct {\n\t// StateDirectory contains the path to the directory that\n\t// should be used to store any data that should be\n\t// preserved between sessions.\n\t//\n\t// Value of this variable must not change after initialization\n\t// in cmd/maddy/main.go.\n\tStateDirectory string\n\n\t// RuntimeDirectory contains the path to the directory that\n\t// should be used to store any temporary data.\n\t//\n\t// It should be preferred over os.TempDir, which is\n\t// global and world-readable on most systems, while\n\t// RuntimeDirectory can be dedicated for maddy.\n\t//\n\t// Value of this variable must not change after initialization\n\t// in cmd/maddy/main.go.\n\tRuntimeDirectory string\n\n\t// LibexecDirectory contains the path to the directory\n\t// where helper binaries should be searched.\n\t//\n\t// Value of this variable must not change after initialization\n\t// in cmd/maddy/main.go.\n\tLibexecDirectory string\n}\n```\n\n```go\ntype LifetimeModule interface {\n\tmodule.Module\n\tStart() error\n\tStop() error\n}\n```\nLifetimeModule is a stateful module that needs to have post-configuration startup and graceful shutdown functionality.\n\n```go\ntype LifetimeTracker struct {\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc NewLifetime(log *log.Logger) *LifetimeTracker\n```\n\n```go\nfunc (lt *LifetimeTracker) Add(mod LifetimeModule)\n```\n\n```go\nfunc (lt *LifetimeTracker) EarlyStopAll() error\n```\n\n```go\nfunc (lt *LifetimeTracker) ReloadAll() error\n```\n\n```go\nfunc (lt *LifetimeTracker) StartAll() error\n```\nStartAll calls Start for all registered LifetimeModule instances.\n\n```go\nfunc (lt *LifetimeTracker) StopAll() error\n```\nStopAll calls Stop for all registered LifetimeModule instances.\n\n```go\ntype Registry struct {\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc NewRegistry(log *log.Logger) *Registry\n```\n\n```go\nfunc (r *Registry) AddAlias(instanceName string, alias string) error\n```\n\n```go\nfunc (r *Registry) Get(name string) (module.Module, error)\n```\n\n```go\nfunc (r *Registry) NotInitialized() []module.Module\n```\n\n```go\nfunc (r *Registry) Register(mod module.Module, lazyInit func() error) error\n```\nRegister adds not-initialized (configured) module into registry.\n\nlazyInit function will be called on first request to get the module from registry.\n\n```go\ntype ReloadModule interface {\n\tmodule.Module\n\tReload() error\n}\n```\n\n","path":"github.com/foxcpp/maddy/framework/container","name":"container","synopsis":"","isRedistributable":true}
