slack

package
v1.70.0 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package slack is a basic Slack API client to send messages via a Webhook.

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" 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(*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