hooks

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EventFileAvailable     = "file.available"
	EventDownloadStarted   = "download.started"
	EventDownloadCompleted = "download.completed"
	EventDownloadFailed    = "download.failed"
	EventDownloadCancelled = "download.cancelled"
	EventChecksumMismatch  = "checksum.mismatch"
	EventSyncCompleted     = "sync.completed"
	EventSyncFailed        = "sync.failed"
)

Variables

This section is empty.

Functions

func AllEvents

func AllEvents() []string

func IsValidEvent

func IsValidEvent(event string) bool

func ParseEvents

func ParseEvents(eventsJSON string) []string

Types

type Alert

type Alert struct {
	Type     string `json:"type"`
	Message  string `json:"message"`
	Severity string `json:"severity"` // "info", "warning", "error"
}

Alert represents an alert in the event payload

type Delivery

type Delivery struct {
	ID   string `json:"id"`
	Name string `json:"name"`
}

Delivery info for event payload

type Error

type Error struct {
	Code    string `json:"code"`
	Message string `json:"message"`
}

Error represents an error in the event payload

type Event

type Event struct {
	Type      string    `json:"event"`
	Timestamp time.Time `json:"timestamp"`
	Source    string    `json:"source"`
	Product   *Product  `json:"product,omitempty"`
	Delivery  *Delivery `json:"delivery,omitempty"`
	File      *File     `json:"file,omitempty"`
	Alerts    []Alert   `json:"alerts,omitempty"`
	Error     *Error    `json:"error,omitempty"`
}

Event represents a hook event

func NewEvent

func NewEvent(eventType, source string) *Event

NewEvent creates a new event with the current timestamp

func (*Event) WithAlert

func (e *Event) WithAlert(alertType, message, severity string) *Event

WithAlert adds an alert

func (*Event) WithDelivery

func (e *Event) WithDelivery(id, name string) *Event

WithDelivery sets the delivery info

func (*Event) WithError

func (e *Event) WithError(code, message string) *Event

WithError sets the error info

func (*Event) WithFile

func (e *Event) WithFile(id, name string, size int64, checksum, path string) *Event

WithFile sets the file info

func (*Event) WithProduct

func (e *Event) WithProduct(id, name string) *Event

WithProduct sets the product info

type File

type File struct {
	ID       string `json:"id"`
	Name     string `json:"name"`
	Size     int64  `json:"size"`
	Checksum string `json:"checksum,omitempty"`
	Path     string `json:"path,omitempty"`
}

File info for event payload

type Manager

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

func New

func New(db *database.DB) *Manager

func (*Manager) CreateWebhook

func (m *Manager) CreateWebhook(name, url string, events []string) (*database.Webhook, error)

func (*Manager) DeleteWebhook

func (m *Manager) DeleteWebhook(id uint) error

func (*Manager) Emit

func (m *Manager) Emit(ctx context.Context, event *Event)

func (*Manager) GetWebhook

func (m *Manager) GetWebhook(id uint) (*database.Webhook, error)

func (*Manager) ListWebhooks

func (m *Manager) ListWebhooks() ([]database.Webhook, error)

func (*Manager) UpdateWebhook

func (m *Manager) UpdateWebhook(id uint, name, url string, events []string, enabled bool) error

type Product

type Product struct {
	ID   string `json:"id"`
	Name string `json:"name"`
}

Product info for event payload

Jump to

Keyboard shortcuts

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