weight

package
v0.0.0-...-bcd23a8 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2025 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Overview

Package weight is a generated GoMock package.

Package weight is a generated GoMock package.

Package weight is a generated GoMock package.

Package weight is a generated GoMock package.

Package weight is a generated GoMock package.

Index

Constants

View Source
const (
	StoppedState = iota
	RunningState
)

Variables

View Source
var (
	ErrQueueClosed = errors.New("queue closed")
	ErrBufFull     = errors.New("buf full")
	ErrBufClosed   = errors.New("buf closed")
)

Functions

func DefaultGlobalWeightConfig

func DefaultGlobalWeightConfig() common.GlobalConfig

Types

type Advanced

type Advanced interface{}

type DLQ

type DLQ interface {
	// Push adds a new event to the dead letter queue.
	// ctx: Context for handling cancellation or timeouts.
	// event: The DLQEvent to be stored in the queue.
	// Returns an error if the operation fails.
	Push(ctx context.Context, event *DLQEvent) error

	// Pop retrieves and removes the oldest event from the queue.
	// ctx: Context for handling cancellation or timeouts.
	// Returns the retrieved DLQEvent and an error if the operation fails.
	Pop(ctx context.Context) (event *DLQEvent, err error)

	// GetSize returns the current number of events in the queue.
	// Returns the size as an int.
	GetSize() int

	// GetAll retrieves all events currently in the queue without removing them.
	// ctx: Context for handling cancellation or timeouts.
	// Returns a slice of DLQEvents and an error if the operation fails.
	GetAll(ctx context.Context) ([]*DLQEvent, error)

	// Remove deletes a specific event from the queue by its ID.
	// ctx: Context for handling cancellation or timeouts.
	// id: The unique identifier of the event to be removed.
	// Returns an error if the operation fails.
	Remove(ctx context.Context, id int64) error

	// Close performs cleanup operations and safely shuts down the queue.
	Close()
}

DLQ (Dead Letter Queue) interface provides functionality to handle failed events. It allows pushing new failed events into the queue, popping events for retry, checking the size of the queue, retrieving all events, removing specific events, and closing the queue when it's no longer needed.

type DLQEvent

type DLQEvent struct {
	// Unique identifier for the event
	ID int64
	// The original event that failed processing
	OriginalEvent Event
	// Human-readable description of why the event failed
	FailReason string
	// The actual error encountered during processing
	Err error
	// Number of times this event has been retried
	RetryTimes int
	// Time when the event was first added to the DLQ
	Timestamp int64
	// Time of the most recent retry attempt
	LastAttempt int64
}

DLQEvent represents a failed event that is stored in the Dead Letter Queue (DLQ). It contains detailed information about the failure, including the original event, reason for failure, error details, retry attempts, and timestamps.

type DLQOss

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

func (*DLQOss) Close

func (d *DLQOss) Close()

Close gracefully shuts down the DLQOss instance, ensuring it is executed only once. It closes the closeCh channel to notify all waiting goroutines, then acquires the mutex lock to perform cleanup operations on the internal buffer. If there are elements in the buffer, it clears each non-nil pointer to help garbage collection and sets the buffer reference to nil.

func (*DLQOss) GetAll

func (d *DLQOss) GetAll(_ context.Context) ([]*DLQEvent, error)

func (*DLQOss) GetSize

func (d *DLQOss) GetSize() int

GetSize returns the current number of events stored in the ring buffer. This method acquires a lock to ensure thread-safe access to the buffer's count.

Returns:

  • int: The current size of the ring buffer, representing the number of stored events.

func (*DLQOss) Pop

func (d *DLQOss) Pop(ctx context.Context) (event *DLQEvent, err error)

func (*DLQOss) Push

func (d *DLQOss) Push(ctx context.Context, event *DLQEvent) error

func (*DLQOss) Remove

func (d *DLQOss) Remove(_ context.Context, _ int64) error

type DistributedDLQ

type DistributedDLQ interface {
	PersistentDLQ

	// ClusterSize returns the number of nodes currently participating in the distributed queue system.
	// This information can be used for load balancing or determining replication factors.
	ClusterSize() int
}

DistributedDLQ extends the PersistentDLQ interface to provide functionality for distributed environments. This interface ensures that dead letter queue operations can be coordinated across multiple nodes in a cluster.

type Event

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

type EventHub

type EventHub interface {
	Register(tag string, sc common.SizeCategory, bufferSize ...int) <-chan Event
	Unregister(tag string)
	Dispatch(ev Event)
	Close()
}

type EventHubImpl

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

EventHubImpl manages event listeners and broadcasts events to them

func (*EventHubImpl) Close

func (d *EventHubImpl) Close()

Close shuts down the dispatcher

func (*EventHubImpl) Dispatch

func (d *EventHubImpl) Dispatch(ev Event)

Dispatch broadcasts an event to all registered listeners Parameters:

ev - event to broadcast

func (*EventHubImpl) Register

func (d *EventHubImpl) Register(tag string, sc common.SizeCategory, bufferSize ...int) <-chan Event

Register adds an event listener to the dispatcher Parameters:

tag - unique identifier for the listener
ch - event channel

func (*EventHubImpl) Unregister

func (d *EventHubImpl) Unregister(tag string)

Unregister removes a listener from the dispatcher Parameters:

tag - unique identifier of the listener to remove

type EventType

type EventType int
const (
	GlobalConfigChange EventType = iota
	SizeClassConfigChange
)

type FileProvider

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

func NewFileProvider

func NewFileProvider(parseType ParseType, filepath string, logger log.Logger) (*FileProvider, error)

func (*FileProvider) Close

func (f *FileProvider) Close()

func (*FileProvider) Watch

func (f *FileProvider) Watch() (<-chan common.Config, error)

type HookResult

type HookResult struct{}

type Listener

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

type Loader

type Loader interface {
	LoadGlobalConfig() (common.GlobalConfig, error)
	LoadSizeClassConfig() (common.SizeClassDetail, error)
	LoadSizeClassDescription() (string, error)
}

type Manager

type Manager interface {
	// Register registers a new listener with the dispatcher.
	// It returns a channel that receives events for the specified size category.
	Register(tag string, sc common.SizeCategory, bufferSize ...int) <-chan Event

	// Unregister removes a listener from the dispatcher.
	Unregister(tag string)

	// Close shuts down the manager and releases all resources.
	Close()
}

func NewManager

func NewManager(provider Provider, processor Processor, eventHub EventHub, l log.Logger) (Manager, error)

NewManager creates a new Manager instance with the provided dependencies.

Parameters:

  • provider: Configuration provider for watching config file changes
  • processor: Processor for normalizing and transforming config data
  • eventHub: Event hub for dispatching config change events
  • l: Logger instance for recording operational logs

Returns:

  • Manager: Initialized manager instance
  • error: Error if initialization fails

type ManagerImpl

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

func (*ManagerImpl) Close

func (m *ManagerImpl) Close()

Close gracefully shuts down the ManagerImpl instance, ensuring all background processes are terminated and resources are released. It performs the following steps:

  1. Attempts to switch the state from RunningState to StoppedState using atomic CAS. If the state is already StoppedState, it returns immediately.
  2. Closes the closeCh channel to signal shutdown to all waiting goroutines.
  3. Waits for all background goroutines to finish via wg.Wait().
  4. Releases resources held by the processor and eventHub components.

func (*ManagerImpl) Register

func (m *ManagerImpl) Register(tag string, sc common.SizeCategory, bufferSize ...int) <-chan Event

Register adds a new event listener to the manager.

Parameters:

  • tag: unique identifier for the listener
  • sc: size category to filter events for this listener
  • bufferSize: optional buffer size for the event channel (default 0)

Returns:

  • <-chan Event: channel that will receive events matching the specified size category

func (*ManagerImpl) Unregister

func (m *ManagerImpl) Unregister(tag string)

Unregister removes a listener from the manager.

Parameters:

  • tag: unique identifier of the listener to remove

type MockAdvanced

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

MockAdvanced is a mock of Advanced interface.

func NewMockAdvanced

func NewMockAdvanced(ctrl *gomock.Controller) *MockAdvanced

NewMockAdvanced creates a new mock instance.

func (*MockAdvanced) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

type MockAdvancedMockRecorder

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

MockAdvancedMockRecorder is the mock recorder for MockAdvanced.

type MockDLQ

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

MockDLQ is a mock of DLQ interface.

func NewMockDLQ

func NewMockDLQ(ctrl *gomock.Controller) *MockDLQ

NewMockDLQ creates a new mock instance.

func (*MockDLQ) Close

func (m *MockDLQ) Close()

Close mocks base method.

func (*MockDLQ) EXPECT

func (m *MockDLQ) EXPECT() *MockDLQMockRecorder

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockDLQ) GetAll

func (m *MockDLQ) GetAll(ctx context.Context) ([]*DLQEvent, error)

GetAll mocks base method.

func (*MockDLQ) GetSize

func (m *MockDLQ) GetSize() (int, error)

GetSize mocks base method.

func (*MockDLQ) Pop

func (m *MockDLQ) Pop(ctx context.Context) (*DLQEvent, error)

Pop mocks base method.

func (*MockDLQ) Push

func (m *MockDLQ) Push(ctx context.Context, event *DLQEvent) error

Push mocks base method.

func (*MockDLQ) Remove

func (m *MockDLQ) Remove(ctx context.Context, id int64) error

Remove mocks base method.

type MockDLQMockRecorder

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

MockDLQMockRecorder is the mock recorder for MockDLQ.

func (*MockDLQMockRecorder) Close

func (mr *MockDLQMockRecorder) Close() *gomock.Call

Close indicates an expected call of Close.

func (*MockDLQMockRecorder) GetAll

func (mr *MockDLQMockRecorder) GetAll(ctx any) *gomock.Call

GetAll indicates an expected call of GetAll.

func (*MockDLQMockRecorder) GetSize

func (mr *MockDLQMockRecorder) GetSize() *gomock.Call

GetSize indicates an expected call of GetSize.

func (*MockDLQMockRecorder) Pop

func (mr *MockDLQMockRecorder) Pop(ctx any) *gomock.Call

Pop indicates an expected call of Pop.

func (*MockDLQMockRecorder) Push

func (mr *MockDLQMockRecorder) Push(ctx, event any) *gomock.Call

Push indicates an expected call of Push.

func (*MockDLQMockRecorder) Remove

func (mr *MockDLQMockRecorder) Remove(ctx, id any) *gomock.Call

Remove indicates an expected call of Remove.

type MockDistributedDLQ

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

MockDistributedDLQ is a mock of DistributedDLQ interface.

func NewMockDistributedDLQ

func NewMockDistributedDLQ(ctrl *gomock.Controller) *MockDistributedDLQ

NewMockDistributedDLQ creates a new mock instance.

func (*MockDistributedDLQ) Close

func (m *MockDistributedDLQ) Close()

Close mocks base method.

func (*MockDistributedDLQ) ClusterSize

func (m *MockDistributedDLQ) ClusterSize() int

ClusterSize mocks base method.

func (*MockDistributedDLQ) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockDistributedDLQ) GetAll

func (m *MockDistributedDLQ) GetAll(ctx context.Context) ([]*DLQEvent, error)

GetAll mocks base method.

func (*MockDistributedDLQ) GetSize

func (m *MockDistributedDLQ) GetSize() (int, error)

GetSize mocks base method.

func (*MockDistributedDLQ) Pop

Pop mocks base method.

func (*MockDistributedDLQ) Push

func (m *MockDistributedDLQ) Push(ctx context.Context, event *DLQEvent) error

Push mocks base method.

func (*MockDistributedDLQ) Recover

func (m *MockDistributedDLQ) Recover() ([]*DLQEvent, error)

Recover mocks base method.

func (*MockDistributedDLQ) Remove

func (m *MockDistributedDLQ) Remove(ctx context.Context, id int64) error

Remove mocks base method.

type MockDistributedDLQMockRecorder

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

MockDistributedDLQMockRecorder is the mock recorder for MockDistributedDLQ.

func (*MockDistributedDLQMockRecorder) Close

Close indicates an expected call of Close.

func (*MockDistributedDLQMockRecorder) ClusterSize

func (mr *MockDistributedDLQMockRecorder) ClusterSize() *gomock.Call

ClusterSize indicates an expected call of ClusterSize.

func (*MockDistributedDLQMockRecorder) GetAll

func (mr *MockDistributedDLQMockRecorder) GetAll(ctx any) *gomock.Call

GetAll indicates an expected call of GetAll.

func (*MockDistributedDLQMockRecorder) GetSize

GetSize indicates an expected call of GetSize.

func (*MockDistributedDLQMockRecorder) Pop

Pop indicates an expected call of Pop.

func (*MockDistributedDLQMockRecorder) Push

func (mr *MockDistributedDLQMockRecorder) Push(ctx, event any) *gomock.Call

Push indicates an expected call of Push.

func (*MockDistributedDLQMockRecorder) Recover

Recover indicates an expected call of Recover.

func (*MockDistributedDLQMockRecorder) Remove

func (mr *MockDistributedDLQMockRecorder) Remove(ctx, id any) *gomock.Call

Remove indicates an expected call of Remove.

type MockEventHub

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

MockEventHub is a mock of EventHub interface.

func NewMockEventHub

func NewMockEventHub(ctrl *gomock.Controller) *MockEventHub

NewMockEventHub creates a new mock instance.

func (*MockEventHub) Close

func (m *MockEventHub) Close()

Close mocks base method.

func (*MockEventHub) Dispatch

func (m *MockEventHub) Dispatch(ev Event)

Dispatch mocks base method.

func (*MockEventHub) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockEventHub) Register

func (m *MockEventHub) Register(tag string, sc common.SizeCategory, bufferSize ...int) <-chan Event

Register mocks base method.

func (*MockEventHub) Unregister

func (m *MockEventHub) Unregister(tag string)

Unregister mocks base method.

type MockEventHubMockRecorder

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

MockEventHubMockRecorder is the mock recorder for MockEventHub.

func (*MockEventHubMockRecorder) Close

func (mr *MockEventHubMockRecorder) Close() *gomock.Call

Close indicates an expected call of Close.

func (*MockEventHubMockRecorder) Dispatch

func (mr *MockEventHubMockRecorder) Dispatch(ev any) *gomock.Call

Dispatch indicates an expected call of Dispatch.

func (*MockEventHubMockRecorder) Register

func (mr *MockEventHubMockRecorder) Register(tag, sc any, bufferSize ...any) *gomock.Call

Register indicates an expected call of Register.

func (*MockEventHubMockRecorder) Unregister

func (mr *MockEventHubMockRecorder) Unregister(tag any) *gomock.Call

Unregister indicates an expected call of Unregister.

type MockPersistentDLQ

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

MockPersistentDLQ is a mock of PersistentDLQ interface.

func NewMockPersistentDLQ

func NewMockPersistentDLQ(ctrl *gomock.Controller) *MockPersistentDLQ

NewMockPersistentDLQ creates a new mock instance.

func (*MockPersistentDLQ) Close

func (m *MockPersistentDLQ) Close()

Close mocks base method.

func (*MockPersistentDLQ) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockPersistentDLQ) GetAll

func (m *MockPersistentDLQ) GetAll(ctx context.Context) ([]*DLQEvent, error)

GetAll mocks base method.

func (*MockPersistentDLQ) GetSize

func (m *MockPersistentDLQ) GetSize() (int, error)

GetSize mocks base method.

func (*MockPersistentDLQ) Pop

Pop mocks base method.

func (*MockPersistentDLQ) Push

func (m *MockPersistentDLQ) Push(ctx context.Context, event *DLQEvent) error

Push mocks base method.

func (*MockPersistentDLQ) Recover

func (m *MockPersistentDLQ) Recover() ([]*DLQEvent, error)

Recover mocks base method.

func (*MockPersistentDLQ) Remove

func (m *MockPersistentDLQ) Remove(ctx context.Context, id int64) error

Remove mocks base method.

type MockPersistentDLQMockRecorder

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

MockPersistentDLQMockRecorder is the mock recorder for MockPersistentDLQ.

func (*MockPersistentDLQMockRecorder) Close

Close indicates an expected call of Close.

func (*MockPersistentDLQMockRecorder) GetAll

func (mr *MockPersistentDLQMockRecorder) GetAll(ctx any) *gomock.Call

GetAll indicates an expected call of GetAll.

func (*MockPersistentDLQMockRecorder) GetSize

func (mr *MockPersistentDLQMockRecorder) GetSize() *gomock.Call

GetSize indicates an expected call of GetSize.

func (*MockPersistentDLQMockRecorder) Pop

Pop indicates an expected call of Pop.

func (*MockPersistentDLQMockRecorder) Push

func (mr *MockPersistentDLQMockRecorder) Push(ctx, event any) *gomock.Call

Push indicates an expected call of Push.

func (*MockPersistentDLQMockRecorder) Recover

func (mr *MockPersistentDLQMockRecorder) Recover() *gomock.Call

Recover indicates an expected call of Recover.

func (*MockPersistentDLQMockRecorder) Remove

func (mr *MockPersistentDLQMockRecorder) Remove(ctx, id any) *gomock.Call

Remove indicates an expected call of Remove.

type MockPluginsDiscover

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

MockPluginsDiscover is a mock of PluginsDiscover interface.

func NewMockPluginsDiscover

func NewMockPluginsDiscover(ctrl *gomock.Controller) *MockPluginsDiscover

NewMockPluginsDiscover creates a new mock instance.

func (*MockPluginsDiscover) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockPluginsDiscover) GetPluginTypes

func (m *MockPluginsDiscover) GetPluginTypes(ctx context.Context) []plugin.TypePlugin

GetPluginTypes mocks base method.

func (*MockPluginsDiscover) GetPluginsByType

func (m *MockPluginsDiscover) GetPluginsByType(ctx context.Context, tp plugin.TypePlugin) []plugin.Plugin

GetPluginsByType mocks base method.

type MockPluginsDiscoverMockRecorder

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

MockPluginsDiscoverMockRecorder is the mock recorder for MockPluginsDiscover.

func (*MockPluginsDiscoverMockRecorder) GetPluginTypes

func (mr *MockPluginsDiscoverMockRecorder) GetPluginTypes(ctx any) *gomock.Call

GetPluginTypes indicates an expected call of GetPluginTypes.

func (*MockPluginsDiscoverMockRecorder) GetPluginsByType

func (mr *MockPluginsDiscoverMockRecorder) GetPluginsByType(ctx, tp any) *gomock.Call

GetPluginsByType indicates an expected call of GetPluginsByType.

type MockPluginsHub

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

MockPluginsHub is a mock of PluginsHub interface.

func NewMockPluginsHub

func NewMockPluginsHub(ctrl *gomock.Controller) *MockPluginsHub

NewMockPluginsHub creates a new mock instance.

func (*MockPluginsHub) CallPlugin

func (m *MockPluginsHub) CallPlugin(ctx context.Context, hookName string, hookFunc func(plugin.Plugin) (any, error)) ([]HookResult, error)

CallPlugin mocks base method.

func (*MockPluginsHub) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockPluginsHub) GetPluginTypes

func (m *MockPluginsHub) GetPluginTypes(ctx context.Context) []plugin.TypePlugin

GetPluginTypes mocks base method.

func (*MockPluginsHub) GetPluginsByType

func (m *MockPluginsHub) GetPluginsByType(ctx context.Context, tp plugin.TypePlugin) []plugin.Plugin

GetPluginsByType mocks base method.

func (*MockPluginsHub) HealthCheck

func (m *MockPluginsHub) HealthCheck(ctx context.Context) map[string]PluginStatus

HealthCheck mocks base method.

func (*MockPluginsHub) InitAll

func (m *MockPluginsHub) InitAll(ctx context.Context) error

InitAll mocks base method.

func (*MockPluginsHub) Register

func (m *MockPluginsHub) Register(ctx context.Context, tp plugin.TypePlugin, arg2 plugin.Plugin) error

Register mocks base method.

func (*MockPluginsHub) RegisterBatch

func (m *MockPluginsHub) RegisterBatch(ctx context.Context, tp plugin.TypePlugin, plugins []plugin.Plugin) error

RegisterBatch mocks base method.

func (*MockPluginsHub) ShutdownAll

func (m *MockPluginsHub) ShutdownAll(ctx context.Context) error

ShutdownAll mocks base method.

func (*MockPluginsHub) StartAll

func (m *MockPluginsHub) StartAll(ctx context.Context) error

StartAll mocks base method.

func (*MockPluginsHub) Unregister

func (m *MockPluginsHub) Unregister(ctx context.Context, tp plugin.TypePlugin, arg2 plugin.Plugin) error

Unregister mocks base method.

func (*MockPluginsHub) UnregisterByName

func (m *MockPluginsHub) UnregisterByName(ctx context.Context, tp plugin.TypePlugin, name string) error

UnregisterByName mocks base method.

type MockPluginsHubMockRecorder

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

MockPluginsHubMockRecorder is the mock recorder for MockPluginsHub.

func (*MockPluginsHubMockRecorder) CallPlugin

func (mr *MockPluginsHubMockRecorder) CallPlugin(ctx, hookName, hookFunc any) *gomock.Call

CallPlugin indicates an expected call of CallPlugin.

func (*MockPluginsHubMockRecorder) GetPluginTypes

func (mr *MockPluginsHubMockRecorder) GetPluginTypes(ctx any) *gomock.Call

GetPluginTypes indicates an expected call of GetPluginTypes.

func (*MockPluginsHubMockRecorder) GetPluginsByType

func (mr *MockPluginsHubMockRecorder) GetPluginsByType(ctx, tp any) *gomock.Call

GetPluginsByType indicates an expected call of GetPluginsByType.

func (*MockPluginsHubMockRecorder) HealthCheck

func (mr *MockPluginsHubMockRecorder) HealthCheck(ctx any) *gomock.Call

HealthCheck indicates an expected call of HealthCheck.

func (*MockPluginsHubMockRecorder) InitAll

func (mr *MockPluginsHubMockRecorder) InitAll(ctx any) *gomock.Call

InitAll indicates an expected call of InitAll.

func (*MockPluginsHubMockRecorder) Register

func (mr *MockPluginsHubMockRecorder) Register(ctx, tp, arg2 any) *gomock.Call

Register indicates an expected call of Register.

func (*MockPluginsHubMockRecorder) RegisterBatch

func (mr *MockPluginsHubMockRecorder) RegisterBatch(ctx, tp, plugins any) *gomock.Call

RegisterBatch indicates an expected call of RegisterBatch.

func (*MockPluginsHubMockRecorder) ShutdownAll

func (mr *MockPluginsHubMockRecorder) ShutdownAll(ctx any) *gomock.Call

ShutdownAll indicates an expected call of ShutdownAll.

func (*MockPluginsHubMockRecorder) StartAll

func (mr *MockPluginsHubMockRecorder) StartAll(ctx any) *gomock.Call

StartAll indicates an expected call of StartAll.

func (*MockPluginsHubMockRecorder) Unregister

func (mr *MockPluginsHubMockRecorder) Unregister(ctx, tp, arg2 any) *gomock.Call

Unregister indicates an expected call of Unregister.

func (*MockPluginsHubMockRecorder) UnregisterByName

func (mr *MockPluginsHubMockRecorder) UnregisterByName(ctx, tp, name any) *gomock.Call

UnregisterByName indicates an expected call of UnregisterByName.

type MockPluginsLifecycle

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

MockPluginsLifecycle is a mock of PluginsLifecycle interface.

func NewMockPluginsLifecycle

func NewMockPluginsLifecycle(ctrl *gomock.Controller) *MockPluginsLifecycle

NewMockPluginsLifecycle creates a new mock instance.

func (*MockPluginsLifecycle) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockPluginsLifecycle) HealthCheck

func (m *MockPluginsLifecycle) HealthCheck(ctx context.Context) map[string]PluginStatus

HealthCheck mocks base method.

func (*MockPluginsLifecycle) InitAll

func (m *MockPluginsLifecycle) InitAll(ctx context.Context) error

InitAll mocks base method.

func (*MockPluginsLifecycle) ShutdownAll

func (m *MockPluginsLifecycle) ShutdownAll(ctx context.Context) error

ShutdownAll mocks base method.

func (*MockPluginsLifecycle) StartAll

func (m *MockPluginsLifecycle) StartAll(ctx context.Context) error

StartAll mocks base method.

type MockPluginsLifecycleMockRecorder

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

MockPluginsLifecycleMockRecorder is the mock recorder for MockPluginsLifecycle.

func (*MockPluginsLifecycleMockRecorder) HealthCheck

func (mr *MockPluginsLifecycleMockRecorder) HealthCheck(ctx any) *gomock.Call

HealthCheck indicates an expected call of HealthCheck.

func (*MockPluginsLifecycleMockRecorder) InitAll

func (mr *MockPluginsLifecycleMockRecorder) InitAll(ctx any) *gomock.Call

InitAll indicates an expected call of InitAll.

func (*MockPluginsLifecycleMockRecorder) ShutdownAll

func (mr *MockPluginsLifecycleMockRecorder) ShutdownAll(ctx any) *gomock.Call

ShutdownAll indicates an expected call of ShutdownAll.

func (*MockPluginsLifecycleMockRecorder) StartAll

func (mr *MockPluginsLifecycleMockRecorder) StartAll(ctx any) *gomock.Call

StartAll indicates an expected call of StartAll.

type MockPluginsManager

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

MockPluginsManager is a mock of PluginsManager interface.

func NewMockPluginsManager

func NewMockPluginsManager(ctrl *gomock.Controller) *MockPluginsManager

NewMockPluginsManager creates a new mock instance.

func (*MockPluginsManager) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockPluginsManager) Register

Register mocks base method.

func (*MockPluginsManager) RegisterBatch

func (m *MockPluginsManager) RegisterBatch(ctx context.Context, tp plugin.TypePlugin, plugins []plugin.Plugin) error

RegisterBatch mocks base method.

func (*MockPluginsManager) Unregister

func (m *MockPluginsManager) Unregister(ctx context.Context, tp plugin.TypePlugin, arg2 plugin.Plugin) error

Unregister mocks base method.

func (*MockPluginsManager) UnregisterByName

func (m *MockPluginsManager) UnregisterByName(ctx context.Context, tp plugin.TypePlugin, name string) error

UnregisterByName mocks base method.

type MockPluginsManagerMockRecorder

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

MockPluginsManagerMockRecorder is the mock recorder for MockPluginsManager.

func (*MockPluginsManagerMockRecorder) Register

func (mr *MockPluginsManagerMockRecorder) Register(ctx, tp, arg2 any) *gomock.Call

Register indicates an expected call of Register.

func (*MockPluginsManagerMockRecorder) RegisterBatch

func (mr *MockPluginsManagerMockRecorder) RegisterBatch(ctx, tp, plugins any) *gomock.Call

RegisterBatch indicates an expected call of RegisterBatch.

func (*MockPluginsManagerMockRecorder) Unregister

func (mr *MockPluginsManagerMockRecorder) Unregister(ctx, tp, arg2 any) *gomock.Call

Unregister indicates an expected call of Unregister.

func (*MockPluginsManagerMockRecorder) UnregisterByName

func (mr *MockPluginsManagerMockRecorder) UnregisterByName(ctx, tp, name any) *gomock.Call

UnregisterByName indicates an expected call of UnregisterByName.

type MockProcessor

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

MockProcessor is a mock of Processor interface.

func NewMockProcessor

func NewMockProcessor(ctrl *gomock.Controller) *MockProcessor

NewMockProcessor creates a new mock instance.

func (*MockProcessor) BuildGlobalStruct

func (m *MockProcessor) BuildGlobalStruct(normalizeConf common.Config) map[common.SizeCategory]float64

BuildGlobalStruct mocks base method.

func (*MockProcessor) BuildSizeClassStruct

func (m *MockProcessor) BuildSizeClassStruct(normalizeConf common.Config) map[common.SizeCategory][]float64

BuildSizeClassStruct mocks base method.

func (*MockProcessor) Close

func (m *MockProcessor) Close()

Close mocks base method.

func (*MockProcessor) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockProcessor) Normalize

func (m *MockProcessor) Normalize(cfg common.Config) (common.Config, error)

Normalize mocks base method.

type MockProcessorMockRecorder

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

MockProcessorMockRecorder is the mock recorder for MockProcessor.

func (*MockProcessorMockRecorder) BuildGlobalStruct

func (mr *MockProcessorMockRecorder) BuildGlobalStruct(normalizeConf any) *gomock.Call

BuildGlobalStruct indicates an expected call of BuildGlobalStruct.

func (*MockProcessorMockRecorder) BuildSizeClassStruct

func (mr *MockProcessorMockRecorder) BuildSizeClassStruct(normalizeConf any) *gomock.Call

BuildSizeClassStruct indicates an expected call of BuildSizeClassStruct.

func (*MockProcessorMockRecorder) Close

func (mr *MockProcessorMockRecorder) Close() *gomock.Call

Close indicates an expected call of Close.

func (*MockProcessorMockRecorder) Normalize

func (mr *MockProcessorMockRecorder) Normalize(cfg any) *gomock.Call

Normalize indicates an expected call of Normalize.

type MockProvider

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

MockProvider is a mock of Provider interface.

func NewMockProvider

func NewMockProvider(ctrl *gomock.Controller) *MockProvider

NewMockProvider creates a new mock instance.

func (*MockProvider) Close

func (m *MockProvider) Close()

Close mocks base method.

func (*MockProvider) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockProvider) Watch

func (m *MockProvider) Watch() (<-chan common.Config, error)

Watch mocks base method.

type MockProviderMockRecorder

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

MockProviderMockRecorder is the mock recorder for MockProvider.

func (*MockProviderMockRecorder) Close

func (mr *MockProviderMockRecorder) Close() *gomock.Call

Close indicates an expected call of Close.

func (*MockProviderMockRecorder) Watch

func (mr *MockProviderMockRecorder) Watch() *gomock.Call

Watch indicates an expected call of Watch.

type MockScheduler

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

MockScheduler is a mock of Scheduler interface.

func NewMockScheduler

func NewMockScheduler(ctrl *gomock.Controller) *MockScheduler

NewMockScheduler creates a new mock instance.

func (*MockScheduler) CallPlugin

func (m *MockScheduler) CallPlugin(ctx context.Context, hookName string, hookFunc func(plugin.Plugin) (any, error)) ([]HookResult, error)

CallPlugin mocks base method.

func (*MockScheduler) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

type MockSchedulerMockRecorder

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

MockSchedulerMockRecorder is the mock recorder for MockScheduler.

func (*MockSchedulerMockRecorder) CallPlugin

func (mr *MockSchedulerMockRecorder) CallPlugin(ctx, hookName, hookFunc any) *gomock.Call

CallPlugin indicates an expected call of CallPlugin.

type ParseType

type ParseType string
const (
	ParseTypeYAML ParseType = "YAML"
	ParseTypeJSON ParseType = "JSON"
	ParseTypeTOML ParseType = "TOML"
)

func (ParseType) String

func (p ParseType) String() string

type PersistentDLQ

type PersistentDLQ interface {
	DLQ

	// Recover retrieves all persisted events from the storage that were not successfully processed.
	// Returns a slice of DLQEvents that need to be retried and an error if the recovery operation fails.
	Recover() ([]*DLQEvent, error)
}

PersistentDLQ extends the DLQ interface with additional functionality for recovering events from persistent storage. This interface is useful in scenarios where queue state needs to be preserved across system restarts or failures.

type PluginStatus

type PluginStatus struct {
	Name string
}

type PluginsDiscover

type PluginsDiscover interface {
	// GetPluginTypes returns a slice of all plugin types currently registered in the system.
	//
	// Parameters:
	//   ctx: Context for managing request-scoped data and cancellation.
	//
	// Returns:
	//   []plugin.TypePlugin: A slice containing all registered plugin types.
	GetPluginTypes(ctx context.Context) []plugin.TypePlugin

	// GetPluginsByType returns all plugins of the specified type.
	//
	// Parameters:
	//   ctx: Context for managing request-scoped data and cancellation.
	//   tp: The type of plugins to retrieve.
	//
	// Returns:
	//   []plugin.Plugin: A slice containing all plugins of the specified type.
	GetPluginsByType(ctx context.Context, tp plugin.TypePlugin) []plugin.Plugin
}

PluginsDiscover provides methods for discovering plugins managed by the PluginsHub. It allows querying registered plugin types and retrieving plugins by type.

type PluginsHub

type PluginsHub interface {
	// PluginsManager defines the interface for managing plugin registration and unregistration operations.
	// It provides methods to register single or batch plugins, and to unregister plugins either by instance
	// or by name.
	PluginsManager
	// PluginsDiscover Provides methods for discovering plugins managed by the PluginsHub.
	// It allows querying registered plugin types and retrieving plugins by type.
	PluginsDiscover
	// PluginsLifecycle Embeds lifecycle management methods (InitAll, StartAll, ShutdownAll, HealthCheck)
	PluginsLifecycle
	// Scheduler provides the capability to invoke plugins at specific hook points.
	// It includes a CallPlugin method that executes applicable plugins under a given hook name,
	// and collects results from each plugin's execution. This interface enables the system
	// to dynamically extend behavior at different stages.
	Scheduler
}

PluginsHub defines a comprehensive interface combining multiple plugin-related capabilities. It embeds several sub-interfaces to manage plugins' lifecycle, registration, discovery, and scheduling functionalities. This interface serves as a central hub for interacting with various types of plugins within the system.

type PluginsHubImpl

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

type PluginsLifecycle

type PluginsLifecycle interface {
	// InitAll initializes all plugins across the system.
	//
	// Parameters:
	//   ctx: Context for managing request-scoped data and cancellation.
	//
	// Returns:
	//   error: If initialization fails, an error is returned; otherwise, nil.
	InitAll(ctx context.Context) error

	// StartAll starts all plugins across the system.
	//
	// Parameters:
	//   ctx: Context for managing request-scoped data and cancellation.
	//
	// Returns:
	//   error: If starting plugins fails, an error is returned; otherwise, nil.
	StartAll(ctx context.Context) error

	// ShutdownAll gracefully shuts down all plugins across the system.
	//
	// Parameters:
	//   ctx: Context for managing request-scoped data and cancellation.
	//
	// Returns:
	//   error: If shutting down plugins fails, an error is returned; otherwise, nil.
	ShutdownAll(ctx context.Context) error

	// HealthCheck performs a health check on all plugins and returns their statuses.
	//
	// Parameters:
	//   ctx: Context for managing request-scoped data and cancellation.
	//
	// Returns:
	//   map[string]PluginStatus: A map containing plugin names as keys and their corresponding status.
	HealthCheck(ctx context.Context) map[string]PluginStatus
}

PluginsLifecycle defines the lifecycle management interface for plugins. It includes methods for initializing, starting, shutting down, and health checking all plugins.

type PluginsManager

type PluginsManager interface {
	// Register adds a single plugin to the manager.
	//
	// Parameters:
	//   ctx: Context for managing request-scoped data and cancellation.
	//   tp: Type of the plugin being registered.
	//   plugin: The plugin instance to register.
	//
	// Returns:
	//   error: If registration fails, an error is returned; otherwise, nil.
	Register(ctx context.Context, tp plugin.TypePlugin, plugin plugin.Plugin) error

	// RegisterBatch adds multiple plugins of the same type to the manager.
	//
	// Parameters:
	//   ctx: Context for managing request-scoped data and cancellation.
	//   tp: Type of the plugins being registered.
	//   plugins: Slice of plugin instances to register.
	//
	// Returns:
	//   error: If batch registration fails, an error is returned; otherwise, nil.
	RegisterBatch(ctx context.Context, tp plugin.TypePlugin, plugins []plugin.Plugin) error

	// Unregister removes a specific plugin from the manager.
	//
	// Parameters:
	//   ctx: Context for managing request-scoped data and cancellation.
	//   tp: Type of the plugin being unregistered.
	//   plugin: The plugin instance to remove.
	//
	// Returns:
	//   error: If unregistration fails, an error is returned; otherwise, nil.
	Unregister(ctx context.Context, tp plugin.TypePlugin, plugin plugin.Plugin) error

	// UnregisterByName removes a plugin by its name rather than its instance.
	//
	// Parameters:
	//   ctx: Context for managing request-scoped data and cancellation.
	//   tp: Type of the plugin being unregistered.
	//   name: Name of the plugin to remove.
	//
	// Returns:
	//   error: If unregistration by name fails, an error is returned; otherwise, nil.
	UnregisterByName(ctx context.Context, tp plugin.TypePlugin, name string) error
}

type Processor

type Processor interface {
	Normalize(cfg common.Config) (common.Config, error)
	BuildGlobalStruct(normalizeConf common.Config) map[common.SizeCategory]float64
	BuildSizeClassStruct(normalizeConf common.Config) map[common.SizeCategory][]float64
	Close()
}

type ProcessorImpl

type ProcessorImpl struct{}

func (*ProcessorImpl) BuildGlobalStruct

func (p *ProcessorImpl) BuildGlobalStruct(normalizeConf common.Config) map[common.SizeCategory]float64

func (*ProcessorImpl) BuildSizeClassStruct

func (p *ProcessorImpl) BuildSizeClassStruct(normalizeConf common.Config) map[common.SizeCategory][]float64

func (*ProcessorImpl) Close

func (p *ProcessorImpl) Close()

func (*ProcessorImpl) Normalize

func (p *ProcessorImpl) Normalize(cfg common.Config) (common.Config, error)

type Provider

type Provider interface {
	Watch() (<-chan common.Config, error)
	Close()
}

type RingBuffer

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

type Scheduler

type Scheduler interface {
	// CallPlugin executes the provided hook function across applicable plugins.
	//
	// Parameters:
	//   ctx: Context for managing request-scoped data and cancellation.
	//   hookName: Name of the hook being executed, used for identifying the context of plugin execution.
	//   hookFunc: Function to apply to each plugin; takes a plugin.Plugin and returns (result any, error).
	//
	// Returns:
	//   []HookResult: A slice containing results from each plugin's execution.
	//   error: If execution fails during the hook process, an error is returned; otherwise, nil.
	CallPlugin(ctx context.Context,
		hookName string,
		hookFunc func(p plugin.Plugin) (any, error)) ([]HookResult, error)
}

Scheduler defines an interface for invoking plugins during specific hooks. It provides a method to call a function across all relevant plugins and collect results.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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