hooks

package
v1.75.6 Latest Latest
Warning

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

Go to latest
Published: May 8, 2026 License: Apache-2.0 Imports: 4 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

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 NewStorage

func NewStorage() *Storage

NewStorage creates a new empty hook storage.

func (*Storage) Add

func (s *Storage) Add(hook *hooks.ModuleHook)

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) Clear

func (s *Storage) Clear()

Clear removes all hooks from storage, resetting it to empty state.

func (*Storage) GetHookByName

func (s *Storage) GetHookByName(name string) *hooks.ModuleHook

GetHookByName returns the hook with the specified name, or nil if not found.

func (*Storage) GetHooks

func (s *Storage) GetHooks() []*hooks.ModuleHook

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) []*hooks.ModuleHook

GetHooksByBinding returns copied slices of all hooks for a specific binding type, sorted by order.

Jump to

Keyboard shortcuts

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