expose ModuleFn type

This commit is contained in:
Elijah Duffy
2025-06-11 18:39:29 -07:00
parent c54a13c40b
commit 816de185e3
3 changed files with 12 additions and 7 deletions

View File

@@ -10,8 +10,8 @@ import (
// ErrModuleNotFound is returned when a module is not found in the lifecycle.
var ErrModuleNotFound = errors.New("module not found")
// moduleFn is a function type for module setup and teardown functions.
type moduleFn func(*Module) error
// ModuleFn is a function type for module setup and teardown functions.
type ModuleFn func(*Module) error
// GenericModule is an interface that allows modules to be extended with custom
// functionality, as the module can return a pointer to the underlying Module.
@@ -26,8 +26,8 @@ type Module struct {
lifecycle *Lifecycle // lifecycle is the parent lifecycle this module belongs to
logger *slog.Logger
name string
setup moduleFn
teardown moduleFn
setup ModuleFn
teardown ModuleFn
depends []string
loaded bool // loaded indicates if the module has been set up
}
@@ -35,9 +35,9 @@ type Module struct {
// ModuleOpts contains user-exposed options when defining a module.
type ModuleOpts struct {
// Setup is the setup function for the module.
Setup moduleFn
Setup ModuleFn
// Teardown is the teardown function for the module.
Teardown moduleFn
Teardown ModuleFn
// Depends is a list of modules that this module depends on. Each entry must
// be the exact name of a module registered in the lifecycle.
Depends []string