threads

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2022 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Manager

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

Manager is a struct that holds configuration to manage concurrent RunnableThreads

func NewManager

func NewManager() Manager

NewManager returns a new initialized Manager struct

func (*Manager) CleanupThreads

func (mgr *Manager) CleanupThreads(instance client.Object) func()

CleanupThreads returns a function that cleans matching threads when invoked. This is intended for use as a cleanup function in the finalize phase of a controller's reconcile loop.

func (*Manager) GetChannel

func (mgr *Manager) GetChannel() <-chan event.GenericEvent

GetChannel returns the channel through which events can be received from the running thread

func (*Manager) ReconcileThreads

func (mgr *Manager) ReconcileThreads(ctx context.Context, instance client.Object, threads []RunnableThread, log logr.Logger) error

ReconcileThreads ensures that the threads identified by the provided keys are running. prefix() is used to identify which threads belong to each resource.

func (*Manager) RunThread

func (mgr *Manager) RunThread(ctx context.Context, key string, thread RunnableThread, log logr.Logger) error

RunThread runs thread and associates it with a given key so it can later be stopped

func (*Manager) StopThread

func (mgr *Manager) StopThread(key string)

StopThread stops the thread identified by the given key

type RunnableThread

type RunnableThread interface {
	GetID() string
	SetChannel(chan event.GenericEvent)
	Start(context.Context, logr.Logger) error
	Stop()
	IsStarted() bool
}

Jump to

Keyboard shortcuts

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