Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type GlobalHook ¶ added in v1.76.0
type GlobalHook interface {
GetName() string
GetConfigVersion() string
GetHookConfig() *addonhooks.GlobalHookConfig
Order(binding shtypes.BindingType) float64
InitializeHookConfig() error
GetHookController() *controller.HookController
WithHookController(ctrl *controller.HookController)
WithTmpDir(tmpDir string)
SynchronizationNeeded() bool
Execute(ctx context.Context, version string, bctx []bctx.BindingContext, packageName string, configValues, values utils.Values, logLabels map[string]string) (*kind.HookResult, error)
}
type GlobalStorage ¶ added in v1.76.0
type GlobalStorage struct {
// contains filtered or unexported fields
}
GlobalStorage provides thread-safe storage for global hooks. It maintains a single index:
- byName: Fast lookup by hook name (O(1))
- byBinding: Fast lookup by binding type (O(1))
Thread Safety: All methods use RWMutex for concurrent access.
func NewGlobalStorage ¶ added in v1.76.0
func NewGlobalStorage() *GlobalStorage
NewGlobalStorage creates a new empty global hook storage.
func (*GlobalStorage) Add ¶ added in v1.76.0
func (s *GlobalStorage) Add(hook GlobalHook)
Add adds a global hook to storage, indexing it by name. If a hook with the same name exists, it will be replaced.
func (*GlobalStorage) Clear ¶ added in v1.76.0
func (s *GlobalStorage) Clear()
Clear removes all hooks from storage, resetting it to empty state.
func (*GlobalStorage) GetHookByName ¶ added in v1.76.0
func (s *GlobalStorage) GetHookByName(name string) GlobalHook
GetHookByName returns the hook with the specified name, or nil if not found.
func (*GlobalStorage) GetHooks ¶ added in v1.76.0
func (s *GlobalStorage) GetHooks() []GlobalHook
GetHooks returns all hooks in storage in arbitrary order. The returned slice is safe to use - it's a copy of internal data.
func (*GlobalStorage) GetHooksByBinding ¶ added in v1.76.0
func (s *GlobalStorage) GetHooksByBinding(binding shtypes.BindingType) []GlobalHook
GetHooksByBinding returns copied slices of all hooks for a specific binding type, sorted by order.
type Hook ¶ added in v1.76.0
type Hook interface {
GetName() string
GetConfigVersion() string
GetHookConfig() *addonhooks.ModuleHookConfig
Order(binding shtypes.BindingType) float64
InitializeHookConfig() error
GetHookController() *controller.HookController
WithHookController(ctrl *controller.HookController)
WithTmpDir(tmpDir string)
SynchronizationNeeded() bool
Execute(ctx context.Context, version string, bctx []bctx.BindingContext, packageName string, configValues, values utils.Values, logLabels map[string]string) (*kind.HookResult, error)
}
Hook represents a module-scoped hook that executes during a module's lifecycle. Module hooks use ModuleHookConfig and are organized by binding type for ordered execution.
type Storage ¶
type Storage struct {
// contains filtered or unexported fields
}
Storage provides thread-safe storage for hooks with multiple access patterns. It maintains two indices:
- byName: Fast lookup by hook name (O(1))
- byBinding: Fast lookup by binding type (O(1))
Thread Safety: All methods use RWMutex for concurrent access.
func (*Storage) Add ¶
Add adds a hook to storage, indexing it by name and all its bindings. If a hook with the same name exists, it will be replaced. Each binding type the hook declares will have the hook added to its list.
func (*Storage) GetHookByName ¶
GetHookByName returns the hook with the specified name, or nil if not found.
func (*Storage) GetHooks ¶
GetHooks returns all hooks in storage in arbitrary order. The returned slice is safe to use - it's a copy of internal data.
func (*Storage) GetHooksByBinding ¶
func (s *Storage) GetHooksByBinding(binding shtypes.BindingType) []Hook
GetHooksByBinding returns copied slices of all hooks for a specific binding type, sorted by order.
func (*Storage) Initialized ¶ added in v1.76.0
Initialized reports whether the hook storage has been fully initialized. It checks if any stored hook has a controller attached — the controller is set during initialization, so its presence indicates that loading is complete. Returns true if the storage is empty (no hooks to initialize) or if hooks have their controllers set.