Documentation
¶
Index ¶
- Constants
- type DefaultHookExecutor
- func (e *DefaultHookExecutor) Clear()
- func (e *DefaultHookExecutor) Disable()
- func (e *DefaultHookExecutor) Enable()
- func (e *DefaultHookExecutor) Execute(ctx context.Context, hook *HookContext) error
- func (e *DefaultHookExecutor) GetHandlerCount(hookType HookType) int
- func (e *DefaultHookExecutor) HasHandlers(hookType HookType) bool
- func (e *DefaultHookExecutor) IsEnabled() bool
- func (e *DefaultHookExecutor) Register(hookType HookType, handler HookHandler) error
- func (e *DefaultHookExecutor) Unregister(hookType HookType)
- type HookContext
- type HookExecutor
- type HookHandler
- type HookType
Constants ¶
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