Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Register ¶
func Register(t models.CallbackType, h Handler)
Register associates a callback type with a handler.
Types ¶
type Dispatcher ¶
type Dispatcher struct {
// contains filtered or unexported fields
}
Dispatcher loads callbacks and invokes handlers.
func Default ¶
func Default() *Dispatcher
Default returns the process-wide dispatcher using the shared DB connection.
func NewDispatcher ¶
func NewDispatcher(conn *gorm.DB) *Dispatcher
NewDispatcher constructs a Dispatcher backed by the provided DB.
func (*Dispatcher) RetryFailed ¶
RetryFailed retries callbacks for the supplied run that most recently failed.
func (*Dispatcher) WithHTTPClient ¶
func (d *Dispatcher) WithHTTPClient(client *http.Client)
WithHTTPClient overrides the HTTP client used by handlers (primarily for tests).
type Metadata ¶
type Metadata struct {
JobID uuid.UUID `json:"job_id"`
JobAlias string `json:"job_alias"`
RunID uuid.UUID `json:"run_id"`
Params map[string]string `json:"params,omitempty"`
Status string `json:"status"`
Error string `json:"error,omitempty"`
StartedAt time.Time `json:"started_at"`
CompletedAt *time.Time `json:"completed_at,omitempty"`
Tasks []TaskState `json:"tasks"`
}
Metadata captures the job/run context sent to callbacks.
type NotificationConfig ¶
type NotificationConfig struct {
URL string `json:"url"`
Webhook string `json:"webhook_url"`
Headers map[string]string `json:"headers,omitempty"`
UserAgent string `json:"user_agent,omitempty"`
}
NotificationConfig describes the webhook target.
type NotificationHandler ¶
type NotificationHandler struct {
// contains filtered or unexported fields
}
NotificationHandler posts run metadata to a webhook endpoint.
func NewNotificationHandler ¶
func NewNotificationHandler(client *http.Client) *NotificationHandler
NewNotificationHandler constructs a notification handler with the provided client.
func (*NotificationHandler) Handle ¶
func (h *NotificationHandler) Handle(ctx context.Context, cfgRaw json.RawMessage, meta Metadata) error
Handle sends a POST request containing the run metadata.
type TaskState ¶
type TaskState struct {
TaskID uuid.UUID `json:"task_id"`
AtomID uuid.UUID `json:"atom_id"`
Engine models.AtomEngine `json:"engine"`
Image string `json:"image"`
Command []string `json:"command"`
RuntimeID string `json:"runtime_id,omitempty"`
Status string `json:"status"`
Result string `json:"result,omitempty"`
Error string `json:"error,omitempty"`
StartedAt *time.Time `json:"started_at,omitempty"`
CompletedAt *time.Time `json:"completed_at,omitempty"`
}
TaskState summarises an individual task run.