hooks

package
v1.74.3 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

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