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 ¶
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 }
Click to show internal directories.
Click to hide internal directories.