Documentation ¶
Index ¶
- Variables
- func CreateReceiversMap(ctx context.Context, receiverService ReceiverService, ...) (map[uint64]*receiver.Receiver, error)
- type CortexClient
- type Filter
- type NamespaceService
- type NotFoundError
- type ProviderService
- type Receiver
- type ReceiverService
- type Repository
- type Service
- func (s Service) Create(ctx context.Context, sub *Subscription) error
- func (s *Service) Delete(ctx context.Context, id uint64) error
- func (s *Service) Get(ctx context.Context, id uint64) (*Subscription, error)
- func (s *Service) List(ctx context.Context, flt Filter) ([]Subscription, error)
- func (s *Service) SyncToUpstream(ctx context.Context, ns *namespace.Namespace, prov *provider.Provider) error
- func (s *Service) Update(ctx context.Context, sub *Subscription) error
- type Subscription
- type Transactor
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 NamespaceService ¶
type NotFoundError ¶
type NotFoundError struct {
ID uint64
}
func (NotFoundError) Error ¶
func (err NotFoundError) Error() string
type ProviderService ¶
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 Repository ¶
type Repository interface { Transactor List(context.Context, Filter) ([]Subscription, error) Create(context.Context, *Subscription) error Get(context.Context, uint64) (*Subscription, error) Update(context.Context, *Subscription) error Delete(context.Context, uint64, uint64) 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) SyncToUpstream ¶
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
Click to show internal directories.
Click to hide internal directories.