notify

package
v0.0.0-...-61a96ab Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2019 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// NSuccess is a success level.
	NSuccess = "SUCCESS"

	// NInfo is information level.
	NInfo = "INFO"

	// NWarning is a warning level.
	NWarning = "WARN"

	// NError is an error level.
	NError = "ERROR"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Backend

type Backend func(handler *Handler) error

Backend is a functional option to configure a sending backend.

func WithGithubPRComment

func WithGithubPRComment(pr int) Backend

WithGithubPRComment is a functional option used in AddComment method.

func WithSlackMessage

func WithSlackMessage(channel string) Backend

WithSlackMessage is a functional option used in AddComment method to se d notification to slack.

type Handler

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

Handler handles notification backends which implement Sender interface.

func NewHandler

func NewHandler(backends ...Sender) *Handler

NewHandler returns a new instance of a Handler and initializes backends.

func (*Handler) AddComment

func (h *Handler) AddComment(ctx context.Context, level NotificationLevel, title, body string, backends ...Backend) error

AddComment adds a new comment to backends.

type Message

type Message struct {
	Title   string
	Body    string
	Channel string
	// contains filtered or unexported fields
}

Message is an object of a slack message

func (Message) Compare

func (m Message) Compare(other queue.Item) int

Compare is an implementation of Item object used by a queue.

type NotificationLevel

type NotificationLevel string

NotificationLevel is a custom type to indicate a message severity.

type Sender

type Sender interface {
	ID() SenderID
	Notify(ctx context.Context, level NotificationLevel, title, body string) error
}

Sender defines a generic interface for notification services. A context object could be used to pass a complex messages as a context value.

func NewGithubCommentSender

func NewGithubCommentSender(maxRetries int, timeout time.Duration, gh github.Client) Sender

NewGithubCommentSender constructs an implementation of github comment notification of Sender interface.

func NewSlackSender

func NewSlackSender(ctx context.Context, apiToken string) Sender

NewSlackSender returns a new instance of slack notification service which implements Sender interface.

type SenderID

type SenderID int

SenderID custom type defines different notification senders

Jump to

Keyboard shortcuts

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