Documentation
¶
Index ¶
- Variables
- func InitAndStart(operator *ShellOperator) error
- func RegisterCommonMetrics(metricStorage *metric_storage.MetricStorage)
- func RegisterHookMetrics(metricStorage *metric_storage.MetricStorage)
- func RegisterKubeEventsManagerMetrics(metricStorage *metric_storage.MetricStorage, labels map[string]string)
- func RegisterShellOperatorMetrics(metricStorage *metric_storage.MetricStorage)
- func RegisterTaskQueueMetrics(metricStorage *metric_storage.MetricStorage)
- type ManagerEventsHandler
- func (m *ManagerEventsHandler) Start()
- func (m *ManagerEventsHandler) Stop()
- func (m *ManagerEventsHandler) WithContext(ctx context.Context)
- func (m *ManagerEventsHandler) WithKubeEventHandler(fn func(kubeEvent KubeEvent) []task.Task)
- func (m *ManagerEventsHandler) WithKubeEventsManager(mgr kube_events_manager.KubeEventsManager)
- func (m *ManagerEventsHandler) WithScheduleEventHandler(fn func(crontab string) []task.Task)
- func (m *ManagerEventsHandler) WithScheduleManager(mgr schedule_manager.ScheduleManager)
- func (m *ManagerEventsHandler) WithTaskQueueSet(tqs *queue.TaskQueueSet)
- type ShellOperator
- func (op *ShellOperator) CombineBindingContextForHook(q *queue.TaskQueue, t task.Task, stopCombineFn func(tsk task.Task) bool) []BindingContext
- func (op *ShellOperator) Init() (err error)
- func (op *ShellOperator) InitAndStartHookQueues()
- func (op *ShellOperator) InitHookManager() (err error)
- func (op *ShellOperator) InitHookMetricStorage()
- func (op *ShellOperator) InitMetricStorage()
- func (op *ShellOperator) PrepopulateMainQueue(tqs *queue.TaskQueueSet)
- func (op *ShellOperator) RunMetrics()
- func (op *ShellOperator) SetupDebugServerHandles()
- func (op *ShellOperator) SetupHookMetricStorageAndServer() error
- func (op *ShellOperator) SetupHttpServerHandles()
- func (op *ShellOperator) Shutdown()
- func (op *ShellOperator) Start()
- func (op *ShellOperator) StartHttpServer(ip string, port string, mux *http.ServeMux) error
- func (op *ShellOperator) Stop()
- func (op *ShellOperator) TaskHandleEnableKubernetesBindings(t task.Task) queue.TaskResult
- func (op *ShellOperator) TaskHandleHookRun(t task.Task) queue.TaskResult
- func (op *ShellOperator) TaskHandler(t task.Task) queue.TaskResult
- func (op *ShellOperator) WithContext(ctx context.Context) *ShellOperator
- func (op *ShellOperator) WithHooksDir(dir string)
- func (op *ShellOperator) WithKubernetesClient(klient kube.KubernetesClient)
- func (op *ShellOperator) WithMetricStorage(metricStorage *metric_storage.MetricStorage)
- func (op *ShellOperator) WithTempDir(dir string)
Constants ¶
This section is empty.
Variables ¶
var WaitQueuesTimeout = time.Second * 10
Functions ¶
func InitAndStart ¶
func InitAndStart(operator *ShellOperator) error
func RegisterCommonMetrics ¶
func RegisterCommonMetrics(metricStorage *metric_storage.MetricStorage)
func RegisterHookMetrics ¶
func RegisterHookMetrics(metricStorage *metric_storage.MetricStorage)
Shell-operator specific metrics
func RegisterKubeEventsManagerMetrics ¶
func RegisterKubeEventsManagerMetrics(metricStorage *metric_storage.MetricStorage, labels map[string]string)
metrics for kube_event_manager
func RegisterShellOperatorMetrics ¶
func RegisterShellOperatorMetrics(metricStorage *metric_storage.MetricStorage)
func RegisterTaskQueueMetrics ¶
func RegisterTaskQueueMetrics(metricStorage *metric_storage.MetricStorage)
Types ¶
type ManagerEventsHandler ¶
type ManagerEventsHandler struct {
// contains filtered or unexported fields
}
func NewManagerEventsHandler ¶
func NewManagerEventsHandler() *ManagerEventsHandler
func (*ManagerEventsHandler) Start ¶
func (m *ManagerEventsHandler) Start()
func (*ManagerEventsHandler) Stop ¶
func (m *ManagerEventsHandler) Stop()
func (*ManagerEventsHandler) WithContext ¶
func (m *ManagerEventsHandler) WithContext(ctx context.Context)
func (*ManagerEventsHandler) WithKubeEventHandler ¶
func (m *ManagerEventsHandler) WithKubeEventHandler(fn func(kubeEvent KubeEvent) []task.Task)
func (*ManagerEventsHandler) WithKubeEventsManager ¶
func (m *ManagerEventsHandler) WithKubeEventsManager(mgr kube_events_manager.KubeEventsManager)
func (*ManagerEventsHandler) WithScheduleEventHandler ¶
func (m *ManagerEventsHandler) WithScheduleEventHandler(fn func(crontab string) []task.Task)
func (*ManagerEventsHandler) WithScheduleManager ¶
func (m *ManagerEventsHandler) WithScheduleManager(mgr schedule_manager.ScheduleManager)
func (*ManagerEventsHandler) WithTaskQueueSet ¶
func (m *ManagerEventsHandler) WithTaskQueueSet(tqs *queue.TaskQueueSet)
type ShellOperator ¶
type ShellOperator struct {
HooksDir string
TempDir string
MetricStorage *metric_storage.MetricStorage
// separate metric storage for hook metrics if separate listen port is configured
HookMetricStorage *metric_storage.MetricStorage
KubeClient kube.KubernetesClient
ScheduleManager schedule_manager.ScheduleManager
KubeEventsManager kube_events_manager.KubeEventsManager
TaskQueues *queue.TaskQueueSet
ManagerEventsHandler *ManagerEventsHandler
HookManager hook.HookManager
DebugServer *debug.Server
// contains filtered or unexported fields
}
func DefaultOperator ¶
func DefaultOperator() *ShellOperator
func NewShellOperator ¶
func NewShellOperator() *ShellOperator
func (*ShellOperator) CombineBindingContextForHook ¶
func (op *ShellOperator) CombineBindingContextForHook(q *queue.TaskQueue, t task.Task, stopCombineFn func(tsk task.Task) bool) []BindingContext
CombineBindingContextForHook combines binding contexts from a sequence of task with similar hook name and task type into array of binding context and delete excess tasks from queue. Also, compacts sequences of binding contexts with similar group. If input task has no metadata, result will be nil. Metadata should implement HookNameAccessor and BindingContextAccessor interfaces.
func (*ShellOperator) Init ¶
func (op *ShellOperator) Init() (err error)
Init does some basic checks and instantiate dependencies
- check directories - start debug server - initialize dependencies:
- metric storage
- kubernetes client config
- empty set of task queues
- hook manager
- kubernetes events manager
- schedule manager
func (*ShellOperator) InitAndStartHookQueues ¶
func (op *ShellOperator) InitAndStartHookQueues()
CreateQueues create all queues defined in hooks
func (*ShellOperator) InitHookManager ¶
func (op *ShellOperator) InitHookManager() (err error)
InitHookManager load hooks from HooksDir and defines event handlers that emit tasks.
func (*ShellOperator) InitHookMetricStorage ¶
func (op *ShellOperator) InitHookMetricStorage()
InitHookMetricStorage creates MetricStorage object with new registry to scrape hook metrics on separate port.
func (*ShellOperator) InitMetricStorage ¶
func (op *ShellOperator) InitMetricStorage()
InitMetricStorage creates default MetricStorage object if not set earlier.
func (*ShellOperator) PrepopulateMainQueue ¶
func (op *ShellOperator) PrepopulateMainQueue(tqs *queue.TaskQueueSet)
PrepopulateMainQueue adds tasks to run hooks with OnStartup bindings and tasks to enable kubernetes bindings.
func (*ShellOperator) RunMetrics ¶
func (op *ShellOperator) RunMetrics()
func (*ShellOperator) SetupDebugServerHandles ¶
func (op *ShellOperator) SetupDebugServerHandles()
func (*ShellOperator) SetupHookMetricStorageAndServer ¶
func (op *ShellOperator) SetupHookMetricStorageAndServer() error
func (*ShellOperator) SetupHttpServerHandles ¶
func (op *ShellOperator) SetupHttpServerHandles()
func (*ShellOperator) Shutdown ¶
func (op *ShellOperator) Shutdown()
Shutdown pause kubernetes events handling and stop queues. Wait for queues to stop.
func (*ShellOperator) Start ¶
func (op *ShellOperator) Start()
func (*ShellOperator) StartHttpServer ¶
func (*ShellOperator) Stop ¶
func (op *ShellOperator) Stop()
func (*ShellOperator) TaskHandleEnableKubernetesBindings ¶
func (op *ShellOperator) TaskHandleEnableKubernetesBindings(t task.Task) queue.TaskResult
func (*ShellOperator) TaskHandleHookRun ¶
func (op *ShellOperator) TaskHandleHookRun(t task.Task) queue.TaskResult
TODO use Context to pass labels and a queue name
func (*ShellOperator) TaskHandler ¶
func (op *ShellOperator) TaskHandler(t task.Task) queue.TaskResult
TaskHandler
func (*ShellOperator) WithContext ¶
func (op *ShellOperator) WithContext(ctx context.Context) *ShellOperator
func (*ShellOperator) WithHooksDir ¶
func (op *ShellOperator) WithHooksDir(dir string)
func (*ShellOperator) WithKubernetesClient ¶
func (op *ShellOperator) WithKubernetesClient(klient kube.KubernetesClient)
func (*ShellOperator) WithMetricStorage ¶
func (op *ShellOperator) WithMetricStorage(metricStorage *metric_storage.MetricStorage)
func (*ShellOperator) WithTempDir ¶
func (op *ShellOperator) WithTempDir(dir string)