webhooks

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2023 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 Manager

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

func NewManager

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

func (*Manager) BroadcastAction

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

func (*Manager) Close

func (w *Manager) Close() error

func (*Manager) Delete

func (w *Manager) Delete(wh Webhook) error

func (*Manager) Info

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

func (*Manager) Register

func (w *Manager) Register(wh Webhook) 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"`
}

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(wh Webhook) error
	AddWebhook(wh Webhook) error
	Webhooks() ([]Webhook, error)
}

Jump to

Keyboard shortcuts

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