notify

package
v0.0.0-...-0db5efb Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2021 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ContentType     = "Content-Type"
	ContentLength   = "Content-Length"
	FormContentType = "application/x-www-form-urlencoded"
	JsonContentType = "application/json"
)

Variables

This section is empty.

Functions

func AddHeaders

func AddHeaders(req *http.Request, headers map[string]string)

func AddNew

func AddNew(notificationTypes NotificationTypes)

Add notification clients given by user in config file to notificationsList

func GetJsonParamsBody

func GetJsonParamsBody(msgParam MessageParam) (io.Reader, error)

func GetUrlValues

func GetUrlValues(msgParam MessageParam) url.Values

func SendErrorNotification

func SendErrorNotification(errorNotification ErrorNotification)

Send Error notification to all clients registered

func SendResponseTimeNotification

func SendResponseTimeNotification(responseTimeNotification ResponseTimeNotification)

Send response time notification to all clients registered

func SendTestNotification

func SendTestNotification()

Send Test notification to all registered clients .To make sure everything is working

Types

type DingdingNotify

type DingdingNotify struct {
	HttpNotify
}

func (DingdingNotify) GetClientName

func (dingdingNotify DingdingNotify) GetClientName() string

func (DingdingNotify) Initialize

func (dingdingNotify DingdingNotify) Initialize() error

func (DingdingNotify) SendErrorNotification

func (dingdingNotify DingdingNotify) SendErrorNotification(errorNotification ErrorNotification) error

func (DingdingNotify) SendResponseTimeNotification

func (dingdingNotify DingdingNotify) SendResponseTimeNotification(responseTimeNotification ResponseTimeNotification) error

type ErrorNotification

type ErrorNotification struct {
	Url          string
	RequestType  string
	ResponseBody string
	Error        string
	OtherInfo    string
}

type HttpNotify

type HttpNotify struct {
	Url         string            `json:"url"`
	RequestType string            `json:"requestType"`
	Headers     map[string]string `json:"headers"`
}

func (HttpNotify) GetClientName

func (httpNotify HttpNotify) GetClientName() string

func (HttpNotify) Initialize

func (httpNotify HttpNotify) Initialize() error

func (HttpNotify) SendErrorNotification

func (httpNotify HttpNotify) SendErrorNotification(errorNotification ErrorNotification) error

func (HttpNotify) SendResponseTimeNotification

func (httpNotify HttpNotify) SendResponseTimeNotification(responseTimeNotification ResponseTimeNotification) error

type MailNotify

type MailNotify struct {
	Username string `json:"username"`
	Password string `json:"password"`
	Host     string `json:"smtpHost"`
	Port     int    `json:"port"`
	From     string `json:"from"`
	To       string `json:"to"`
}

func (MailNotify) GetClientName

func (mailNotify MailNotify) GetClientName() string

func (MailNotify) Initialize

func (mailNotify MailNotify) Initialize() error

func (MailNotify) SendErrorNotification

func (mailNotify MailNotify) SendErrorNotification(errorNotification ErrorNotification) error

func (MailNotify) SendResponseTimeNotification

func (mailNotify MailNotify) SendResponseTimeNotification(responseTimeNotification ResponseTimeNotification) error

type MailgunNotify

type MailgunNotify struct {
	Email        string `json:"email"`
	ApiKey       string `json:"apiKey"`
	Domain       string `json:"domain"`
	PublicApiKey string `json:"publicApiKey"`
}

func (MailgunNotify) GetClientName

func (mailgunNotify MailgunNotify) GetClientName() string

func (MailgunNotify) Initialize

func (mailgunNotify MailgunNotify) Initialize() error

func (MailgunNotify) SendErrorNotification

func (mailgunNotify MailgunNotify) SendErrorNotification(errorNotification ErrorNotification) error

func (MailgunNotify) SendResponseTimeNotification

func (mailgunNotify MailgunNotify) SendResponseTimeNotification(responseTimeNotification ResponseTimeNotification) error

type Message

type Message struct {
	MessageType string `json:"msgtype"`
	Text        Txt    `json:"text"`
}

type MessageParam

type MessageParam struct {
	Message string `json:"message"`
}

type NotificationTypes

type NotificationTypes struct {
	MailNotify MailNotify      `json:"mail"`
	Mailgun    MailgunNotify   `json:"mailGun"`
	Slack      SlackNotify     `json:"slack"`
	Http       HttpNotify      `json:"httpEndPoint"`
	Dingding   DingdingNotify  `json:"dingding"`
	Pagerduty  PagerdutyNotify `json:"pagerduty"`
}

Diffrent types of clients to deliver notifications

type Notify

type Notify interface {
	GetClientName() string
	Initialize() error
	SendResponseTimeNotification(notification ResponseTimeNotification) error
	SendErrorNotification(notification ErrorNotification) error
}

type PagerdutyNotify

type PagerdutyNotify struct {
	Url        string `json:"url"`
	RoutingKey string `json:"routingKey"`
	Severity   string `json:"severity"`
}

func (PagerdutyNotify) GetClientName

func (pagerdutyNotify PagerdutyNotify) GetClientName() string

func (PagerdutyNotify) Initialize

func (pagerdutyNotify PagerdutyNotify) Initialize() error

func (PagerdutyNotify) SendErrorNotification

func (pagerdutyNotify PagerdutyNotify) SendErrorNotification(errorNotification ErrorNotification) error

func (PagerdutyNotify) SendResponseTimeNotification

func (pagerdutyNotify PagerdutyNotify) SendResponseTimeNotification(responseTimeNotification ResponseTimeNotification) error

type Payload

type Payload struct {
	Summary   string `json:"summary"`
	Timestamp string `json:"timestamp"`
	Source    string `json:"source"`
	Severity  string `json:"severity"`
}

type RequestBody

type RequestBody struct {
	Payload     Payload `json:"payload"`
	RoutingKey  string  `json:"routing_key"`
	DedupKey    string  `json:"dedup_key"`
	EventAction string  `json:"event_action"`
}

func CreatePagerdutyRequest

func CreatePagerdutyRequest(url, summary string, config PagerdutyNotify) RequestBody

type ResponseTimeNotification

type ResponseTimeNotification struct {
	Url                  string
	RequestType          string
	ExpectedResponsetime int64
	MeanResponseTime     int64
}

type SlackNotify

type SlackNotify struct {
	Username          string `json:"username"`
	ChannelName       string `json:"channelName"` //Not mandatory field
	ChannelWebhookURL string `json:"channelWebhookURL"`
	IconUrl           string `json:"iconUrl"`
}

func (SlackNotify) GetClientName

func (slackNotify SlackNotify) GetClientName() string

func (SlackNotify) Initialize

func (slackNotify SlackNotify) Initialize() error

func (SlackNotify) SendErrorNotification

func (slackNotify SlackNotify) SendErrorNotification(errorNotification ErrorNotification) error

func (SlackNotify) SendResponseTimeNotification

func (slackNotify SlackNotify) SendResponseTimeNotification(responseTimeNotification ResponseTimeNotification) error

type Txt

type Txt struct {
	Content string `json:"content"`
}

Jump to

Keyboard shortcuts

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