slack

package
v1.11.0 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2025 License: MIT Imports: 4 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type NoopNotifier

type NoopNotifier struct{}

NoopNotifier is a Notifier that does nothing, used when Slack notifications are disabled

func (*NoopNotifier) SendError

func (n *NoopNotifier) SendError(ctx context.Context, summary string, err error, details map[string]interface{}) error

type Notifier

type Notifier interface {
	SendError(ctx context.Context, summary string, err error, details map[string]interface{}) error
}

Notifier represents an interface for a generic notifier

func NewSlackNotifier

func NewSlackNotifier(slackConfig *SlackConfig) Notifier

NewSlackNotifier creates a new SlackNotifier if slack is enabled in the config, otherwise it returns a NoopNotifier

type SlackClient

type SlackClient interface {
	PostMessage(channelID string, options ...slack.MsgOption) (string, string, error)
}

SlackClient is an interface to enable mocking of the slack-go/slack.Client

type SlackConfig

type SlackConfig struct {
	APIToken string `envconfig:"SLACK_API_TOKEN"`
	Username string `envconfig:"SLACK_USERNAME"`
	Channel  string `envconfig:"SLACK_CHANNEL"`
	Emoji    string `envconfig:"SLACK_EMOJI"`
	Enabled  bool   `envconfig:"SLACK_ENABLED"`
}

SlackConfig holds configuration for sending Slack notifications

type SlackNotifier

type SlackNotifier struct {
	Client   SlackClient
	Username string
	Channel  string
	Emoji    string
}

SlackNotifier is a Notifier that uses slack-go/slack.Client to send notifications

func (*SlackNotifier) SendError

func (n *SlackNotifier) SendError(ctx context.Context, summary string, err error, details map[string]interface{}) error

SendError formats an error message with a summary, error, and optional details, then sends it to the Slack channel

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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