notify

package
v0.0.0-...-49d8a77 Latest Latest
Warning

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

Go to latest
Published: May 26, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Author

type Author struct {
	Name    string `json:"name"`
	URL     string `json:"url"`
	IconURL string `json:"icon_url"`
}

type CustomNotifier

type CustomNotifier struct {
	URL     string            `json:"url" validate:"url"`
	Method  string            `json:"http_method" validate:"oneof=GET HEAD POST PUT PATCH DELETE CONNECT OPTIONS TRACE"`
	Headers map[string]string `json:"http_headers"`
	Body    string            `json:"body"`

	ExpectHTTPCode int `json:"expect_http_code" validate:"min=100,max=599"`
}

func (*CustomNotifier) Do

func (c *CustomNotifier) Do(ctx context.Context, cli *resty.Client, res *models.Result) error

func (*CustomNotifier) Name

func (c *CustomNotifier) Name() string

type DiscordNotifier

type DiscordNotifier struct {
	URL string `json:"url" validate:"url"`
}

func (*DiscordNotifier) Do

func (d *DiscordNotifier) Do(ctx context.Context, cli *resty.Client, res *models.Result) error

func (*DiscordNotifier) Name

func (d *DiscordNotifier) Name() string

type DiscordWebhook

type DiscordWebhook struct {
	Username  string   `json:"username"`
	AvatarURL string   `json:"avatar_url"`
	Content   string   `json:"content"`
	Embeds    []*Embed `json:"embeds"`
}

type Embed

type Embed struct {
	Author      Author  `json:"author"`
	Title       string  `json:"title"`
	URL         string  `json:"url"`
	Description string  `json:"description"`
	Color       int64   `json:"color"`
	Fields      []Field `json:"fields"`
	Thumbnail   Image   `json:"thumbnail"`
	Image       Image   `json:"image"`
	Footer      Footer  `json:"footer"`
}

func AsDiscordEmbed

func AsDiscordEmbed(r *models.Result) *Embed

type Field

type Field struct {
	Name   string `json:"name"`
	Value  string `json:"value"`
	Inline bool   `json:"inline,omitempty"`
}
type Footer struct {
	Text    string `json:"text"`
	IconURL string `json:"icon_url"`
}

type HealthCheck

type HealthCheck struct {
	URL string `json:"url" validate:"url"`
}

func (*HealthCheck) Do

func (h *HealthCheck) Do(ctx context.Context, cli *resty.Client, res *models.Result) error

func (*HealthCheck) Name

func (h *HealthCheck) Name() string

type Image

type Image struct {
	URL string `json:"url"`
}

type Notifier

type Notifier interface {
	Do(ctx context.Context, cli *resty.Client, res *models.Result) error
}

func InitNotifier

func InitNotifier(msg []byte) (Notifier, error)

func InitNotifiers

func InitNotifiers(msgs [][]byte) ([]Notifier, error)

func NewCustomNotifier

func NewCustomNotifier(msg json.RawMessage) (Notifier, error)

func NewDiscordNotifier

func NewDiscordNotifier(msg json.RawMessage) (Notifier, error)

func NewHealthChecker

func NewHealthChecker(msg json.RawMessage) (Notifier, error)

type NotifierFactory

type NotifierFactory func(msg json.RawMessage) (Notifier, error)

Jump to

Keyboard shortcuts

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