receiver

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: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TypeSlack     string = "slack"
	TypeHTTP      string = "http"
	TypePagerDuty string = "pagerduty"
	TypeFile      string = "file"
)

Variables

View Source
var (
	ErrNotImplemented = errors.New("operation not supported")
)
View Source
var SupportedTypes = []string{
	TypeSlack,
	TypeHTTP,
	TypePagerDuty,
	TypeFile,
}

Functions

func IsTypeSupported added in v0.5.0

func IsTypeSupported(receiverType string) bool

Types

type ConfigResolver added in v0.5.0

type ConfigResolver interface {
	BuildData(ctx context.Context, configs map[string]interface{}) (map[string]interface{}, error)
	PreHookDBTransformConfigs(ctx context.Context, configs map[string]interface{}) (map[string]interface{}, error)
	PostHookDBTransformConfigs(ctx context.Context, configs map[string]interface{}) (map[string]interface{}, error)
}

ConfigResolver is an interface for the receiver to resolve all configs and function related to a specific receiver type. Receiver plugin needs to implement this interface for all configs and functionality resolution.

type Encryptor

type Encryptor interface {
	Encrypt(str string) (string, error)
	Decrypt(str string) (string, error)
}

type Filter

type Filter struct {
	ReceiverIDs []uint64
}

type GetOption added in v0.5.2

type GetOption func(*getOpts)

func GetWithData added in v0.5.2

func GetWithData(withData bool) GetOption

type NotFoundError

type NotFoundError struct {
	ID uint64
}

func (NotFoundError) Error

func (err NotFoundError) Error() string

type Receiver

type Receiver struct {
	ID             uint64                 `json:"id"`
	Name           string                 `json:"name"`
	Labels         map[string]string      `json:"labels"`
	Configurations map[string]interface{} `json:"configurations"`
	Data           map[string]interface{} `json:"data"`
	CreatedAt      time.Time              `json:"created_at"`
	UpdatedAt      time.Time              `json:"updated_at"`

	// Type should be immutable
	Type string `json:"type"`
}

type Repository

type Repository interface {
	List(context.Context, Filter) ([]Receiver, error)
	Create(context.Context, *Receiver) error
	Get(context.Context, uint64) (*Receiver, error)
	Update(context.Context, *Receiver) error
	Delete(context.Context, uint64) error
}

type Service

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

Service handles business logic

func NewService

func NewService(repository Repository, receiverPlugins map[string]ConfigResolver) *Service

func (*Service) Create

func (s *Service) Create(ctx context.Context, rcv *Receiver) 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, gopts ...GetOption) (*Receiver, error)

func (*Service) List

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

func (*Service) Update

func (s *Service) Update(ctx context.Context, rcv *Receiver) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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