watchers

package
v0.0.0-...-5f3b442 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUnmatchedMsgType            = errors.New("message type does not match the one configured for the batcher")
	DefaultBatchDuration           = 2 * time.Second
	DefaultMinBatchSize            = 4
	DefaultFailureBatchMessageFunc = func(batchSize int, crd string) string {
		return fmt.Sprintf("%s: %d failed", crd, batchSize)
	}
	DefaultSuccessBatchMessageFunc = func(batchSize int, crd string) string {
		return fmt.Sprintf("%s: %d successful", crd, batchSize)
	}
)

Functions

func StartDestinationWatcher

func StartDestinationWatcher(ctx context.Context, namespace string) error

func StartInstrumentationInstanceWatcher

func StartInstrumentationInstanceWatcher(ctx context.Context, namespace string) error

func StartInstrumentedApplicationWatcher

func StartInstrumentedApplicationWatcher(ctx context.Context, namespace string) error

Types

type EventBatcher

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

func NewEventBatcher

func NewEventBatcher(config EventBatcherConfig) *EventBatcher

func (*EventBatcher) AddEvent

func (eb *EventBatcher) AddEvent(msgType sse.MessageType, data, target string) error

func (*EventBatcher) Cancel

func (eb *EventBatcher) Cancel()

type EventBatcherConfig

type EventBatcherConfig struct {
	// Event to batch, not configuring this value (empty string) will cause to all events to be batched
	Event sse.MessageEvent
	// Message type to batch, not configuring this value (empty string) will cause all messages to be batched
	MessageType sse.MessageType
	// Time to wait before sending a batch of notifications
	Duration time.Duration
	// Minimum number of notifications to batch, if the batch size is less than this, the messages will be sent individually
	MinBatchSize int
	// CRD type to batch, TODO: should we allow this to be empty?
	CRDType string
	// Function to generate a message for a batch of failed messages
	FailureBatchMessageFunc func(batchSize int, crd string) string
	// Function to generate a message for a batch of successful messages
	SuccessBatchMessageFunc func(batchSize int, crd string) string
}

Jump to

Keyboard shortcuts

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