dispatcher

package
v0.0.0-...-2369383 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2025 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Dispatcher

type Dispatcher interface {
	// Start initializes and runs the dispatcher based on different implementations.
	Start(ctx context.Context)
	// Dispatch determines if the current Maestro instance should process the resource status update based on the consumer ID.
	Dispatch(consumerName string) bool
}

Dispatcher defines methods for coordinating resource status updates in the context of multiple active maestro instances.

The dispatcher ensures only one instance processes specific resource status updates from a consumer. It needs to handle status resync based on the instances' status and different implementations.

type HashDispatcher

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

HashDispatcher is an implementation of Dispatcher. It uses consistent hashing to map consumers to maestro instances. Only the maestro instance that is mapped to a consumer will process the resource status update from that consumer. Need to trigger status resync for the consumer when an instance is up or down.

func NewHashDispatcher

func NewHashDispatcher(instanceID string, sessionFactory db.SessionFactory, sourceClient cloudevents.SourceClient, consistentHashingConfig *config.ConsistentHashConfig) *HashDispatcher

func (*HashDispatcher) Dispatch

func (d *HashDispatcher) Dispatch(consumerName string) bool

Dispatch checks if the provided consumer ID is owned by the current maestro instance. It returns true if the consumer is part of the current instance's consumer set; otherwise, it returns false.

func (*HashDispatcher) Start

func (d *HashDispatcher) Start(ctx context.Context)

Start initializes and runs the dispatcher, updating the hashing ring and consumer set for the current instance.

type NoopDispatcher

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

NoopDispatcher is a no-op implementation of Dispatcher. It will always dispatch the resource status update to the current maestro instance. This is the default implementation when shared subscription is enabled. Need to trigger status resync from all consumers when an instance is down.

func NewNoopDispatcher

func NewNoopDispatcher(sessionFactory db.SessionFactory, sourceClient cloudevents.SourceClient) *NoopDispatcher

NewNoopDispatcher creates a new NoopDispatcher instance.

func (*NoopDispatcher) Dispatch

func (d *NoopDispatcher) Dispatch(consumerID string) bool

Dispatch always returns true, indicating that the current maestro instance should process the resource status update.

func (*NoopDispatcher) Start

func (d *NoopDispatcher) Start(ctx context.Context)

Start is a no-op implementation.

Jump to

Keyboard shortcuts

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