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: 0

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