Documentation
¶
Overview ¶
Package dispatch delivers chat lifecycle events to an external webhook.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CapacityClass ¶
type CapacityClass int
CapacityClass selects which share of dispatch capacity an event draws from.
const ( CapacityClassUnset CapacityClass = iota CapacityClassAdmission CapacityClassGeneration )
type Dispatcher ¶
type Dispatcher struct {
// contains filtered or unexported fields
}
Dispatcher delivers lifecycle hook attempts. It keeps no delivery or decision state, so delivery is best-effort and consumers own both.
func New ¶
func New( logger slog.Logger, client *http.Client, hookURL string, allowInsecureURL bool, secret string, timeout time.Duration, deploymentID string, coderVersion string, reg prometheus.Registerer, ) *Dispatcher
New copies (or creates) the HTTP client and disables redirects for signed requests.
func (*Dispatcher) Dispatch ¶
func (d *Dispatcher) Dispatch(ctx context.Context, event Event) (agenthooks.Response, uuid.UUID, error)
Dispatch delivers one event. The returned ID correlates the attempt in logs and Error values; the dispatcher does not persist delivery state.
func (*Dispatcher) Enabled ¶
func (d *Dispatcher) Enabled() bool
Enabled reports whether a hook URL is configured. A nil dispatcher reads as disabled so callers can hold one unconditionally.
type Event ¶
type Event struct {
Type agenthooks.EventType
agenthooks.ChatRef
Data any
Capacity CapacityClass
}
Event carries the identities delivered with each dispatch attempt.
type Result ¶
type Result string
Result classifies the terminal outcome of a dispatch attempt.
const ( ResultOK Result = "ok" ResultDenied Result = "denied" ResultHTTPError Result = "http_error" ResultProtocolError Result = "protocol_error" ResultTimeout Result = "timeout" ResultConnectionError Result = "connection_error" ResultOverCapacity Result = "over_capacity" ResultInternalError Result = "internal_error" )