slack

package
v1.99.6 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package slack is a basic client for the official Slack API used to send messages via a Webhook.

This package is based on https://api.slack.com/messaging/webhooks and provides a simple interface for sending messages to a Slack channel.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client is the implementation of the service client.

func New

func New(addr, username, iconEmoji, iconURL, channel string, opts ...Option) (*Client, error)

New creates a new instance of the Slack service client. The arguments other than "addr" (Slack Webhook URL) are optional, they can be set in the Webhook configuration or in each individual message.

func (*Client) HealthCheck

func (c *Client) HealthCheck(ctx context.Context) error

HealthCheck performs a status check on this service.

func (*Client) Send

func (c *Client) Send(ctx context.Context, text, username, iconEmoji, iconURL, channel string) error

Send a message accounting for the default values. The arguments after "text" can be left empty to get the default values.

type HTTPClient

type HTTPClient interface {
	Do(req *http.Request) (*http.Response, error)
}

HTTPClient contains the function to perform the actual HTTP request.

type Option

type Option func(c *Client)

Option is the interface that allows to set client options.

func WithHTTPClient

func WithHTTPClient(hc HTTPClient) Option

WithHTTPClient overrides the default HTTP client.

func WithPingTimeout

func WithPingTimeout(timeout time.Duration) Option

WithPingTimeout overrides the default ping timeout.

func WithPingURL

func WithPingURL(pingURL string) Option

WithPingURL overrides the default ping timeout.

func WithRetryAttempts

func WithRetryAttempts(attempts uint) Option

WithRetryAttempts overrides the default HTTP client.

func WithTimeout

func WithTimeout(timeout time.Duration) Option

WithTimeout overrides the default request timeout.

Jump to

Keyboard shortcuts

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