handler

package
v0.36.3 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ErrInsufficientPermissions represents the error in case of insufficient permissions (RBAC) to perform an operation.
	ErrInsufficientPermissions druidapicommon.ErrorCode = "ERR_INSUFFICIENT_PERMISSIONS"
	// ErrGetEtcd represents the error in case of fetching etcd object.
	ErrGetEtcd druidapicommon.ErrorCode = "ERR_GET_ETCD"
	// ErrDuplicateTask represents the error in case of a duplicate task for the same etcd.
	ErrDuplicateTask druidapicommon.ErrorCode = "ERR_DUPLICATE_TASK"
	// ErrGetCASecret represents the error in case of failure in fetching the CA secret
	ErrGetCASecret druidapicommon.ErrorCode = "ERR_GET_CA_SECRET" // #nosec G101
	// ErrCADataKeyNotFound represents the error when CA cert data key is not found in secret
	ErrCADataKeyNotFound druidapicommon.ErrorCode = "ERR_CA_DATA_KEY_NOT_FOUND"
	// ErrAppendCACerts represents the error when failed to append CA certs from secret
	ErrAppendCACerts druidapicommon.ErrorCode = "ERR_APPEND_CA_CERTS"
	// ErrDeleteEtcdOpsTask represents the error in case of failure in deleting EtcdOpsTask object.
	ErrDeleteEtcdOpsTask druidapicommon.ErrorCode = "ERR_DELETE_ETCD_OPS_TASK"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Handler

type Handler interface {
	// Admit checks if the task is permitted to run. This is a one-time gate; once passed, it is not checked again for the same task execution.
	Admit(ctx context.Context) Result
	// Execute executes the main logic of the task. Is executed after Admit has returned a successful result.
	Execute(ctx context.Context) Result
	// Cleanup performs any necessary cleanup after task execution, regardless of success or failure.
	Cleanup(ctx context.Context) Result
}

Handler defines the interface for task execution.

type Result

type Result struct {
	Description string
	Error       error
	Requeue     bool
}

Result defines the result of a task execution.

type TaskHandlerFactory

type TaskHandlerFactory func(k8sClient client.Client, task *v1alpha1.EtcdOpsTask, httpClient *http.Client) (Handler, error)

TaskHandlerFactory defines a function signature for creating task handlers.

type TaskHandlerRegistry

type TaskHandlerRegistry interface {
	// Register registers a task handler factory for a given task type.
	Register(taskType string, factory TaskHandlerFactory)
	// GetHandler creates and returns a task handler for the given task type.
	GetHandler(taskType string, k8sClient client.Client, task *v1alpha1.EtcdOpsTask, httpClient *http.Client) (Handler, error)
}

TaskHandlerRegistry manages the registration and retrieval of task handlers.

func NewTaskHandlerRegistry

func NewTaskHandlerRegistry() TaskHandlerRegistry

NewTaskHandlerRegistry creates a new task handler registry.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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