subscription

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2022 License: Apache-2.0 Imports: 11 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)

Types

type CortexClient

type CortexClient interface {
	CreateAlertmanagerConfig(cortex.AlertManagerConfig, string) error
	CreateRuleGroup(ctx context.Context, namespace string, rg rwrulefmt.RuleGroup) error
	DeleteRuleGroup(ctx context.Context, namespace, groupName string) error
	GetRuleGroup(ctx context.Context, namespace, groupName string) (*rwrulefmt.RuleGroup, error)
	ListRules(ctx context.Context, namespace string) (map[string][]rwrulefmt.RuleGroup, error)
}

type Filter

type Filter struct {
	NamespaceID uint64
}

type NotFoundError

type NotFoundError struct {
	ID uint64
}

func (NotFoundError) Error

func (err NotFoundError) Error() string

type Receiver

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

type ReceiverService

type ReceiverService interface {
	List(ctx context.Context, flt receiver.Filter) ([]receiver.Receiver, error)
	Create(ctx context.Context, rcv *receiver.Receiver) error
	Get(ctx context.Context, id uint64) (*receiver.Receiver, error)
	Update(ctx context.Context, rcv *receiver.Receiver) error
	Delete(ctx context.Context, id uint64) error
	Notify(ctx context.Context, id uint64, payloadMessage receiver.NotificationMessage) error
	GetSubscriptionConfig(subsConfs map[string]string, rcv *receiver.Receiver) (map[string]string, error)
}

type Service

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

Service handles business logic

func NewService

func NewService(repository Repository, providerService ProviderService, namespaceService NamespaceService,
	receiverService ReceiverService, cortexClient CortexClient) *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) SyncToUpstream

func (s *Service) SyncToUpstream(
	ctx context.Context,
	ns *namespace.Namespace,
	prov *provider.Provider) 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(receiverService ReceiverService, receiversMap map[uint64]*receiver.Receiver, subscriptions []Subscription) ([]Subscription, error)

func (*Subscription) ToAlertManagerReceiverConfig

func (s *Subscription) ToAlertManagerReceiverConfig() []cortex.ReceiverConfig

type Transactor

type Transactor interface {
	WithTransaction(ctx context.Context) context.Context
	Rollback(ctx context.Context, err error) error
	Commit(ctx context.Context) error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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