destregistry

package
v0.1.0-alpha.6 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrPublisherClosed = errors.New("publisher is closed")

Functions

func MakePublisherKey

func MakePublisherKey(dest *models.Destination) string

MakePublisherKey creates a unique key for a destination that includes type and config

func NewErrDestinationPublishAttempt

func NewErrDestinationPublishAttempt(err error, provider string, data map[string]interface{}) error

func NewErrDestinationValidation

func NewErrDestinationValidation(errors []ValidationErrorDetail) error

func ObfuscateValue

func ObfuscateValue(value string) string

ObfuscateValue masks a sensitive value with the following rules: - For strings with length >= 10: show first 4 characters + asterisks for the rest - For strings with length < 10: replace each character with an asterisk

Types

type BaseProvider

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

BaseProvider provides common functionality for all destination providers

func NewBaseProvider

func NewBaseProvider(loader metadata.MetadataLoader, providerType string) (*BaseProvider, error)

NewBaseProvider creates a new base provider with loaded metadata

func (*BaseProvider) Metadata

func (p *BaseProvider) Metadata() *metadata.ProviderMetadata

Metadata returns the provider metadata

func (*BaseProvider) ObfuscateDestination

func (p *BaseProvider) ObfuscateDestination(destination *models.Destination) *models.Destination

ObfuscateDestination returns a copy of the destination with sensitive fields masked

func (*BaseProvider) Preprocess

func (p *BaseProvider) Preprocess(newDestination *models.Destination, originalDestination *models.Destination, opts *PreprocessDestinationOpts) error

Preprocess is a noop by default

func (*BaseProvider) Validate

func (p *BaseProvider) Validate(ctx context.Context, destination *models.Destination) error

Validate performs field-level validation using the provider's metadata

type BasePublisher

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

BasePublisher provides common publisher functionality

func (*BasePublisher) FinishPublish

func (p *BasePublisher) FinishPublish()

FinishPublish marks a publish operation as complete

func (*BasePublisher) StartClose

func (p *BasePublisher) StartClose()

StartClose marks publisher as closed and waits for active operations

func (*BasePublisher) StartPublish

func (p *BasePublisher) StartPublish() error

StartPublish returns error if publisher is closed, otherwise adds to waitgroup

type Config

type Config struct {
	DestinationMetadataPath string
	PublisherCacheSize      int
	PublisherTTL            time.Duration
	DeliveryTimeout         time.Duration
}

type Delivery

type Delivery struct {
	Status   string
	Code     string
	Response map[string]interface{}
}

type DestinationDisplay

type DestinationDisplay struct {
	*models.Destination
	Target string `json:"target"`
}

DestinationDisplay represents a destination with display-specific fields

type ErrDestinationPublishAttempt

type ErrDestinationPublishAttempt struct {
	Err      error
	Provider string
	Data     map[string]interface{}
}

func (*ErrDestinationPublishAttempt) Error

type ErrDestinationValidation

type ErrDestinationValidation struct {
	Errors []ValidationErrorDetail `json:"errors"`
}

func (*ErrDestinationValidation) Error

func (e *ErrDestinationValidation) Error() string

type PreprocessDestinationOpts

type PreprocessDestinationOpts struct {
	Role string
}

PreprocessDestinationOpts contains options for preprocessing a destination

type Provider

type Provider interface {
	// Validate destination configuration using metadata
	Validate(ctx context.Context, destination *models.Destination) error
	// Create a new publisher instance
	CreatePublisher(ctx context.Context, destination *models.Destination) (Publisher, error)
	// Get provider metadata
	Metadata() *metadata.ProviderMetadata
	// ObfuscateDestination returns a copy of the destination with sensitive fields masked
	ObfuscateDestination(destination *models.Destination) *models.Destination
	// ComputeTarget returns a human-readable target string for the destination
	ComputeTarget(destination *models.Destination) string
	// Preprocess modifies the destination before it is stored in the DB
	Preprocess(newDestination *models.Destination, originalDestination *models.Destination, opts *PreprocessDestinationOpts) error
}

Provider interface handles validation and publisher creation

type Publisher

type Publisher interface {
	Publish(ctx context.Context, event *models.Event) (*Delivery, error)
	Close() error
}

type Registry

type Registry interface {
	// Operations
	ValidateDestination(ctx context.Context, destination *models.Destination) error
	PublishEvent(ctx context.Context, destination *models.Destination, event *models.Event) (*models.Delivery, error)
	DisplayDestination(destination *models.Destination) (*DestinationDisplay, error)
	PreprocessDestination(newDestination *models.Destination, originalDestination *models.Destination, opts *PreprocessDestinationOpts) error

	// Provider management
	RegisterProvider(destinationType string, provider Provider) error
	ResolveProvider(destination *models.Destination) (Provider, error)
	ResolvePublisher(ctx context.Context, destination *models.Destination) (Publisher, error)

	// Metadata access
	MetadataLoader() metadata.MetadataLoader
	RetrieveProviderMetadata(providerType string) (*metadata.ProviderMetadata, error)
	ListProviderMetadata() []*metadata.ProviderMetadata
}

Registry manages providers, their metadata, and publishers

func NewRegistry

func NewRegistry(cfg *Config, logger *logging.Logger) Registry

type ValidationErrorDetail

type ValidationErrorDetail struct {
	Field string `json:"field"`
	Type  string `json:"type"`
}

Directories

Path Synopsis
internal/destregistry/metadata/types.go
internal/destregistry/metadata/types.go

Jump to

Keyboard shortcuts

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