webhooks

package
v1.1.0-beta.1 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2024 License: MIT Imports: 11 Imported by: 1

Documentation

Index

Constants

View Source
const (
	WebhookEventPing = "ping"
)

Variables

View Source
var ErrWebhookNotFound = errors.New("Webhook not found")

Functions

This section is empty.

Types

type Broadcaster

type Broadcaster interface {
	BroadcastAction(ctx context.Context, action Event) error
}

type Event

type Event struct {
	Module  string      `json:"module"`
	Event   string      `json:"event"`
	Payload interface{} `json:"payload,omitempty"`
}

Event describes an event that has been triggered.

func (Event) String

func (a Event) String() string

type HeaderOption added in v1.0.8

type HeaderOption func(headers map[string]string)

func WithBasicAuth added in v1.0.8

func WithBasicAuth(username, password string) HeaderOption

type Manager

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

func NewManager

func NewManager(store WebhookStore, logger *zap.Logger) (*Manager, error)

func (*Manager) BroadcastAction

func (m *Manager) BroadcastAction(_ context.Context, event Event) error

func (*Manager) Delete

func (m *Manager) Delete(ctx context.Context, wh Webhook) error

func (*Manager) Info

func (m *Manager) Info() ([]Webhook, []WebhookQueueInfo)

func (*Manager) Register

func (m *Manager) Register(ctx context.Context, wh Webhook) error

func (*Manager) Shutdown added in v1.1.0

func (m *Manager) Shutdown(ctx context.Context) error

type NoopBroadcaster

type NoopBroadcaster struct{}

func (NoopBroadcaster) BroadcastAction

func (NoopBroadcaster) BroadcastAction(_ context.Context, _ Event) error

type Webhook

type Webhook struct {
	Module  string            `json:"module"`
	Event   string            `json:"event"`
	URL     string            `json:"url"`
	Headers map[string]string `json:"headers,omitempty"`
}

func (Webhook) Matches

func (w Webhook) Matches(action Event) bool

func (Webhook) String

func (w Webhook) String() string

type WebhookQueueInfo

type WebhookQueueInfo struct {
	URL  string `json:"url"`
	Size int    `json:"size"`
}

type WebhookStore

type WebhookStore interface {
	DeleteWebhook(ctx context.Context, wh Webhook) error
	AddWebhook(ctx context.Context, wh Webhook) error
	Webhooks(ctx context.Context) ([]Webhook, error)
}

Jump to

Keyboard shortcuts

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