Help us shape the future of Go! Take the 2026 Go Developer Survey

subscription

package
v0.5.9 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrDuplicate = errors.New("urn already exist")
	ErrRelation  = errors.New("namespace id does not exist")
)

Functions

func CreateReceiversMap

func CreateReceiversMap(ctx context.Context, receiverService ReceiverService, subscriptions []Subscription) (map[uint64]*receiver.Receiver, error)

func MergeConfigsMap added in v0.5.0

func MergeConfigsMap(subscriptionConfigMap map[string]interface{}, receiverConfigsMap map[string]interface{}) map[string]interface{}

Types

type Filter

type Filter struct {
	NamespaceID       uint64
	Match             map[string]string
	NotificationMatch map[string]string
	SilenceID         string
	IDs               []int64
}

type LogService added in v0.5.8

type LogService interface {
	ListSubscriptionIDsBySilenceID(ctx context.Context, silenceID string) ([]int64, error)
}

type NotFoundError

type NotFoundError struct {
	ID uint64
}

func (NotFoundError) Error

func (err NotFoundError) Error() string

type Receiver

type Receiver struct {
	ID            uint64                 `json:"id"`
	Configuration map[string]interface{} `json:"configuration"`

	// Type won't be exposed to the end-user, this is used to add more details for notification purposes
	Type string
}

type ReceiverService

type ReceiverService interface {
	List(ctx context.Context, flt receiver.Filter) ([]receiver.Receiver, error)
}

type Service

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

Service handles business logic

func NewService

func NewService(repository Repository, logService LogService, namespaceService NamespaceService, receiverService ReceiverService) *Service

NewService returns service struct

func (*Service) Create

func (s *Service) Create(ctx context.Context, sub *Subscription) error

func (*Service) Delete

func (s *Service) Delete(ctx context.Context, id uint64) error

func (*Service) Get

func (s *Service) Get(ctx context.Context, id uint64) (*Subscription, error)

func (*Service) List

func (s *Service) List(ctx context.Context, flt Filter) ([]Subscription, error)

func (*Service) MatchByLabels added in v0.5.0

func (s *Service) MatchByLabels(ctx context.Context, namespaceID uint64, notificationLabels map[string]string) ([]Subscription, error)

func (*Service) Update

func (s *Service) Update(ctx context.Context, sub *Subscription) error

type Subscription

type Subscription struct {
	ID        uint64            `json:"id"`
	URN       string            `json:"urn"`
	Namespace uint64            `json:"namespace"`
	Receivers []Receiver        `json:"receivers"`
	Match     map[string]string `json:"match"`
	CreatedAt time.Time         `json:"created_at"`
	UpdatedAt time.Time         `json:"updated_at"`
}

func AssignReceivers

func AssignReceivers(receiversMap map[uint64]*receiver.Receiver, subscriptions []Subscription) ([]Subscription, error)

func (Subscription) ReceiversAsMap added in v0.5.8

func (s Subscription) ReceiversAsMap() map[uint64]Receiver

func (Subscription) SilenceReceivers added in v0.5.8

func (s Subscription) SilenceReceivers(silences []silence.Silence) (map[uint64][]silence.Silence, []Receiver, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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