receiver

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

Documentation

Index

Constants

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

Variables

View Source
var (
	ErrNotImplemented = errors.New("operation not supported")
)

Functions

This section is empty.

Types

type Configurations

type Configurations map[string]interface{}

func (Configurations) GetString

func (c Configurations) GetString(key string) (string, error)

type Encryptor

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

type Filter

type Filter struct {
	ReceiverIDs []uint64
}

type HTTPService

type HTTPService struct{}

func NewHTTPService

func NewHTTPService() *HTTPService

NewHTTPService returns slack service struct

func (*HTTPService) Decrypt

func (s *HTTPService) Decrypt(r *Receiver) error

func (*HTTPService) Encrypt

func (s *HTTPService) Encrypt(r *Receiver) error

func (*HTTPService) GetSubscriptionConfig

func (s *HTTPService) GetSubscriptionConfig(subsConfs map[string]string, receiverConfs Configurations) (map[string]string, error)

func (*HTTPService) Notify

func (s *HTTPService) Notify(ctx context.Context, rcv *Receiver, payloadMessage NotificationMessage) error

func (*HTTPService) PopulateReceiver

func (s *HTTPService) PopulateReceiver(ctx context.Context, rcv *Receiver) (*Receiver, error)

func (*HTTPService) ValidateConfiguration

func (s *HTTPService) ValidateConfiguration(rcv *Receiver) error

type NotFoundError

type NotFoundError struct {
	ID uint64
}

func (NotFoundError) Error

func (err NotFoundError) Error() string

type NotificationMessage

type NotificationMessage map[string]interface{}

NotificationMessage is an abstraction of receiver's notification message

func (NotificationMessage) ToSlackMessage

func (nm NotificationMessage) ToSlackMessage() (*slack.Message, error)

ToSlackMessage

{
	"receiver_name": "",
	"receiver_type": "",
	"message": "",
	"blocks": [
			{
				"": ""
			}
		]
}

type PagerDutyService

type PagerDutyService struct{}

func NewPagerDutyService

func NewPagerDutyService() *PagerDutyService

NewPagerDutyService returns slack service struct

func (*PagerDutyService) Decrypt

func (s *PagerDutyService) Decrypt(r *Receiver) error

func (*PagerDutyService) Encrypt

func (s *PagerDutyService) Encrypt(r *Receiver) error

func (*PagerDutyService) GetSubscriptionConfig

func (s *PagerDutyService) GetSubscriptionConfig(subsConfs map[string]string, receiverConfs Configurations) (map[string]string, error)

func (*PagerDutyService) Notify

func (s *PagerDutyService) Notify(ctx context.Context, rcv *Receiver, payloadMessage NotificationMessage) error

func (*PagerDutyService) PopulateReceiver

func (s *PagerDutyService) PopulateReceiver(ctx context.Context, rcv *Receiver) (*Receiver, error)

func (*PagerDutyService) ValidateConfiguration

func (s *PagerDutyService) ValidateConfiguration(rcv *Receiver) error

type Receiver

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

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, registry map[string]TypeService) *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) (*Receiver, error)

func (*Service) GetSubscriptionConfig

func (s *Service) GetSubscriptionConfig(subsConfs map[string]string, rcv *Receiver) (map[string]string, error)

func (*Service) List

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

func (*Service) Notify

func (s *Service) Notify(ctx context.Context, id uint64, payloadMessage NotificationMessage) error

func (*Service) Update

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

type SlackClient

type SlackClient interface {
	GetWorkspaceChannels(ctx context.Context, opts ...slack.ClientCallOption) ([]slack.Channel, error)
	Notify(ctx context.Context, message *slack.Message, opts ...slack.ClientCallOption) error
}

type SlackService

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

func NewSlackService

func NewSlackService(slackClient SlackClient, cryptoClient Encryptor) *SlackService

NewService returns slack service struct

func (*SlackService) Decrypt

func (s *SlackService) Decrypt(r *Receiver) error

func (*SlackService) Encrypt

func (s *SlackService) Encrypt(r *Receiver) error

func (*SlackService) GetSubscriptionConfig

func (s *SlackService) GetSubscriptionConfig(subsConfs map[string]string, receiverConfs Configurations) (map[string]string, error)

func (*SlackService) Notify

func (s *SlackService) Notify(ctx context.Context, rcv *Receiver, payloadMessage NotificationMessage) error

func (*SlackService) PopulateReceiver

func (s *SlackService) PopulateReceiver(ctx context.Context, rcv *Receiver) (*Receiver, error)

func (*SlackService) ValidateConfiguration

func (s *SlackService) ValidateConfiguration(rcv *Receiver) error

type TypeService

type TypeService interface {
	Encrypt(r *Receiver) error
	Decrypt(r *Receiver) error
	PopulateReceiver(ctx context.Context, rcv *Receiver) (*Receiver, error)
	Notify(ctx context.Context, rcv *Receiver, payloadMessage NotificationMessage) error
	ValidateConfiguration(rcv *Receiver) error
	GetSubscriptionConfig(subsConfs map[string]string, receiverConfs Configurations) (map[string]string, error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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