webhooks

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package webhooks defines the ticket and article events GoatFlow publishes to outbound webhooks and turns database changes into those events.

Index

Constants

View Source
const (
	// RetentionDaysEnv sets the retention in days; 0 keeps deliveries forever.
	RetentionDaysEnv     = "GOATFLOW_WEBHOOK_DELIVERY_RETENTION_DAYS"
	DefaultRetentionDays = 30
)

Delivery log retention. Delivered and failed deliveries older than the retention are deleted by the dispatcher at most once per pruneInterval.

View Source
const (
	EventTicketCreated         = "ticket.created"
	EventTicketUpdated         = "ticket.updated"
	EventTicketStateChanged    = "ticket.state_changed"
	EventTicketClosed          = "ticket.closed"
	EventTicketQueueMoved      = "ticket.queue_moved"
	EventTicketAssigned        = "ticket.assigned"
	EventTicketPriorityChanged = "ticket.priority_changed"
	EventTicketMerged          = "ticket.merged"
	EventTicketEscalated       = "ticket.escalated"
	EventArticleCreated        = "article.created"
)

Event types a webhook can subscribe to.

Variables

View Source
var Events = []EventInfo{
	{EventTicketCreated, "A ticket was created (any channel)."},
	{EventTicketUpdated, "Ticket title, customer, type, service, SLA, responsible, lock, pending time or a dynamic field changed."},
	{EventTicketStateChanged, "The ticket state changed to a state that is not closed."},
	{EventTicketClosed, "The ticket state changed to a closed state."},
	{EventTicketQueueMoved, "The ticket moved to another queue."},
	{EventTicketAssigned, "The ticket owner changed."},
	{EventTicketPriorityChanged, "The ticket priority changed."},
	{EventTicketMerged, "The ticket was merged."},
	{EventTicketEscalated, "A response, update or solution time escalation started."},
	{EventArticleCreated, "An article (note, reply, email, phone call, web request) was added to a ticket."},
}

Events is the catalogue of subscribable events, in display order.

Functions

func IsEvent added in v0.10.0

func IsEvent(name string) bool

IsEvent reports whether name is a subscribable event.

Types

type EventInfo added in v0.10.0

type EventInfo struct {
	Event       string `json:"event"`
	Description string `json:"description"`
}

EventInfo describes one subscribable event.

type Service added in v0.10.0

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

Service turns ticket, article and history rows into webhook deliveries, sends due deliveries and prunes the delivery log. Run it periodically from a single goroutine per process (the runner task does); several processes may run it concurrently.

func NewService added in v0.10.0

func NewService(db *sql.DB) *Service

NewService returns a service on db.

func (*Service) RunOnce added in v0.10.0

func (s *Service) RunOnce(ctx context.Context) (queued, attempted int, err error)

RunOnce publishes new events, sends due deliveries until none are left or ctx expires, and prunes the delivery log when it is due. It returns how many events were queued and how many delivery attempts were made.

Jump to

Keyboard shortcuts

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