dispatchers

package
v0.0.0-...-ebc7474 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxRetryAttempts      = 5
	DefaultRequestTimeout = 3*time.Second + 50*time.Millisecond // Close to 3.05
	DefaultServiceURL     = "https://example.com/api"           // Replace with actual URL
)

Constants for retry attempts and request timeout

Variables

This section is empty.

Functions

This section is empty.

Types

type Dispatcher

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

func (*Dispatcher) Dispatch

func (d *Dispatcher) Dispatch(ctx context.Context, alert alerts.Alert) bool

func (*Dispatcher) Name

func (d *Dispatcher) Name() string

type DispatcherConstructor

type DispatcherConstructor func(config map[string]string) (IDispatcher, error)

type DispatcherError

type DispatcherError struct {
	Message string
}

DispatcherError custom error for Dispather

func (*DispatcherError) Error

func (e *DispatcherError) Error() string

type DispatcherOption

type DispatcherOption func(*Dispatcher)

func Config

func Config(config map[string]any) DispatcherOption

func ID

func ID(id string) DispatcherOption

func Name

func Name(name string) DispatcherOption

func URL

func URL(url string) DispatcherOption

type DispatcherRepository

type DispatcherRepository struct {
	Dispatchers map[string]DispatcherConstructor
	// contains filtered or unexported fields
}

func GetDispatcherRepository

func GetDispatcherRepository() *DispatcherRepository

func NewDispatcherRepository

func NewDispatcherRepository() DispatcherRepository

func (*DispatcherRepository) CreateDispatcher

func (dpr *DispatcherRepository) CreateDispatcher(name string, config map[string]string) (IDispatcher, error)

func (*DispatcherRepository) GetDispatcher

func (dpr *DispatcherRepository) GetDispatcher(name string) (DispatcherConstructor, error)

func (*DispatcherRepository) HasDispatcher

func (dpr *DispatcherRepository) HasDispatcher(name string) bool

func (*DispatcherRepository) RegisterDispatcher

func (dpr *DispatcherRepository) RegisterDispatcher(name string, constructor DispatcherConstructor) error

type IDispatcher

type IDispatcher interface {
	Dispatch(ctx context.Context, alert alerts.Alert) bool
	Name() string
	String() string
}

IDispatcher interface with required methods

Jump to

Keyboard shortcuts

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