hooks

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HookPreDownload  = types.PreDownloadHook
	HookPostDownload = types.PostDownloadHook
	HookPreChunk     = types.CustomHook
	HookPostChunk    = types.CustomHook
	HookOnError      = types.ErrorHook
	HookOnRetry      = types.CustomHook
	HookOnProgress   = types.CustomHook
	HookOnComplete   = types.PostDownloadHook
)

Variables

This section is empty.

Functions

This section is empty.

Types

type DefaultHookExecutor added in v1.3.1

type DefaultHookExecutor struct {
	// contains filtered or unexported fields
}

DefaultHookExecutor is the default implementation of HookExecutor

func NewHookExecutor added in v1.3.1

func NewHookExecutor() *DefaultHookExecutor

NewHookExecutor creates a new DefaultHookExecutor

func (*DefaultHookExecutor) Clear added in v1.3.1

func (e *DefaultHookExecutor) Clear()

Clear removes all registered handlers

func (*DefaultHookExecutor) Disable added in v1.3.1

func (e *DefaultHookExecutor) Disable()

Disable disables hook execution

func (*DefaultHookExecutor) Enable added in v1.3.1

func (e *DefaultHookExecutor) Enable()

Enable enables hook execution

func (*DefaultHookExecutor) Execute added in v1.3.1

func (e *DefaultHookExecutor) Execute(ctx context.Context, hook *HookContext) error

Execute runs all registered handlers for the given hook type

func (*DefaultHookExecutor) GetHandlerCount added in v1.3.1

func (e *DefaultHookExecutor) GetHandlerCount(hookType HookType) int

GetHandlerCount returns the number of handlers registered for a hook type

func (*DefaultHookExecutor) HasHandlers added in v1.3.1

func (e *DefaultHookExecutor) HasHandlers(hookType HookType) bool

HasHandlers returns whether any handlers are registered for a hook type

func (*DefaultHookExecutor) IsEnabled added in v1.3.1

func (e *DefaultHookExecutor) IsEnabled() bool

IsEnabled returns whether hook execution is enabled

func (*DefaultHookExecutor) Register added in v1.3.1

func (e *DefaultHookExecutor) Register(hookType HookType, handler HookHandler) error

Register adds a new handler for the specified hook type

func (*DefaultHookExecutor) Unregister added in v1.3.1

func (e *DefaultHookExecutor) Unregister(hookType HookType)

Unregister removes all handlers for the specified hook type

type HookContext

type HookContext struct {
	Type     HookType
	Data     interface{}
	Metadata map[string]interface{}
	Cancel   context.CancelFunc
}

HookContext provides context and data for hook execution

type HookExecutor

type HookExecutor interface {
	Execute(ctx context.Context, hook *HookContext) error
	Register(hookType HookType, handler HookHandler) error
}

HookExecutor interface for executing and registering hooks

type HookHandler

type HookHandler func(ctx context.Context, hookCtx *HookContext) error

HookHandler represents a function that handles a specific hook

type HookType

type HookType = types.HookType

HookType represents different types of hooks in the system

Jump to

Keyboard shortcuts

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