Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrProjectNotFound = errors.New("project not found") ErrProjectAlreadyExists = errors.New("project already exists") )
Functions ¶
This section is empty.
Types ¶
type ActionRepo ¶
type ActionRepo interface {
// Run operations
GetRun(ctx context.Context, runID *common.RunIdentifier) (*models.Run, error)
// AbortRun marks only the root action as ABORTED and sets abort_requested_at on it.
// K8s cascades CRD deletion to child actions via OwnerReferences; the action service
// informer handles marking them ABORTED in DB when their CRDs are deleted.
AbortRun(ctx context.Context, runID *common.RunIdentifier, reason string, abortedBy *common.EnrichedIdentity) error
// Action operations
CreateAction(ctx context.Context, action *models.Action, updateTriggeredAt bool) (*models.Action, error)
InsertEvents(ctx context.Context, events []*models.ActionEvent) error
ListEvents(ctx context.Context, actionID *common.ActionIdentifier, limit int) ([]*models.ActionEvent, error)
ListEventsSince(ctx context.Context, actionID *common.ActionIdentifier, attempt uint32, since time.Time, offset, limit int) ([]*models.ActionEvent, error)
GetLatestEventByAttempt(ctx context.Context, actionID *common.ActionIdentifier, attempt uint32) (*models.ActionEvent, error)
GetAction(ctx context.Context, actionID *common.ActionIdentifier) (*models.Action, error)
ListActions(ctx context.Context, input ListResourceInput) ([]*models.Action, error)
UpdateActionPhase(ctx context.Context, actionID *common.ActionIdentifier, phase common.ActionPhase, attempts uint32, cacheStatus core.CatalogCacheStatus, endTime *time.Time) error
// AbortAction marks only the targeted action as ABORTED and sets abort_requested_at.
// K8s cascades CRD deletion to descendants via OwnerReferences.
AbortAction(ctx context.Context, actionID *common.ActionIdentifier, reason string, abortedBy *common.EnrichedIdentity) error
// Abort reconciliation — used by the background AbortReconciler.
ListPendingAborts(ctx context.Context) ([]*models.Action, error)
MarkAbortAttempt(ctx context.Context, actionID *common.ActionIdentifier) (attemptCount int, err error)
ClearAbortRequest(ctx context.Context, actionID *common.ActionIdentifier) error
// Watch operations (for streaming)
WatchRunUpdates(ctx context.Context, runID *common.RunIdentifier, updates chan<- *models.Run, errs chan<- error)
WatchAllRunUpdates(ctx context.Context, updates chan<- *models.Run, errs chan<- error)
WatchAllActionUpdates(ctx context.Context, runID *common.RunIdentifier, updates chan<- *models.Action, errs chan<- error)
WatchActionUpdates(ctx context.Context, actionID *common.ActionIdentifier, updates chan<- *models.Action, errs chan<- error)
// State operations
UpdateActionState(ctx context.Context, actionID *common.ActionIdentifier, state string) error
GetActionState(ctx context.Context, actionID *common.ActionIdentifier) (string, error)
// Event notification (for state updates)
NotifyStateUpdate(ctx context.Context, actionID *common.ActionIdentifier) error
WatchStateUpdates(ctx context.Context, updates chan<- *common.ActionIdentifier, errs chan<- error)
// Aggregation operations
ListRootActions(ctx context.Context, project, domain string, startDate, endDate *time.Time, limit int) ([]*models.Action, error)
}
ActionRepo defines the interface for actions/runs data access
type FilterExpression ¶
type FilterExpression = int
const ( FilterExpressionEqual FilterExpression = iota FilterExpressionNotEqual FilterExpressionGreaterThan FilterExpressionGreaterThanOrEqual FilterExpressionLessThan FilterExpressionLessThanOrEqual FilterExpressionContains FilterExpressionValueIn FilterExpressionEndsWith FilterExpressionNotEndsWith FilterExpressionContainsCaseInsensitive )
Set of filters available for database queries.
type ListResourceInput ¶
type ListResourceInput struct {
Limit int
// CursorToken is a keyset pagination cursor encoded as a RFC3339Nano timestamp.
// When set, the query returns rows with created_at strictly greater than the cursor value.
// Mutually exclusive with Offset.
CursorToken string
// Offset is an integer offset for offset-based pagination.
Offset int
Filter Filter
// The filter set by scopeBy in the query
ScopeByFilter Filter
SortParameters []SortParameter
}
ListResourceInput contains parameters for querying collections of resources.
func (ListResourceInput) WithFilter ¶
func (l ListResourceInput) WithFilter(filter Filter) ListResourceInput
func (ListResourceInput) WithSortParameters ¶
func (l ListResourceInput) WithSortParameters(sortParameters ...SortParameter) ListResourceInput
type ProjectRepo ¶ added in v2.0.8
type ProjectRepo interface {
CreateProject(ctx context.Context, project *models.Project) error
GetProject(ctx context.Context, identifier string) (*models.Project, error)
UpdateProject(ctx context.Context, project *models.Project) error
ListProjects(ctx context.Context, input ListResourceInput) ([]*models.Project, error)
}
type QueryExpr ¶ added in v2.0.12
type QueryExpr struct {
Query string
Args []interface{}
}
QueryExpr is a container for arguments necessary to issue a query.
type Repository ¶
type Repository interface {
ActionRepo() ActionRepo
TaskRepo() TaskRepo
TriggerRepo() TriggerRepo
}
type SortParameter ¶
type SortParameter interface {
GetOrderExpr() string
}
type TaskRepo ¶
type TaskRepo interface {
// CreateTask upserts a task and its associated triggers in one transaction.
// Trigger models are optional; pass nil or an empty slice if there are no triggers.
CreateTask(ctx context.Context, task *models.Task, triggers []*models.Trigger) error
GetTask(ctx context.Context, key models.TaskKey) (*models.Task, error)
ListTasks(ctx context.Context, input ListResourceInput) (*models.TaskListResult, error)
ListVersions(ctx context.Context, input ListResourceInput) ([]*models.TaskVersion, error)
CreateTaskSpec(ctx context.Context, taskSpec *models.TaskSpec) error
GetTaskSpec(ctx context.Context, digest string) (*models.TaskSpec, error)
}
type TriggerNameKey ¶ added in v2.0.12
TriggerNameKey is a lightweight identity tuple used for batch operations.
func NewTriggerNameKey ¶ added in v2.0.12
func NewTriggerNameKey(project, domain, taskName, name string) TriggerNameKey
NewTriggerNameKey constructs a TriggerNameKey.
type TriggerRepo ¶ added in v2.0.12
type TriggerRepo interface {
// SaveTrigger inserts or updates the latest trigger state and appends a revision row.
// expectedRevision is the caller's current LatestRevision for optimistic locking.
// Pass 0 when creating a brand-new trigger.
SaveTrigger(ctx context.Context, trigger *models.Trigger, expectedRevision uint64) (*models.Trigger, error)
// GetTrigger returns the latest (non-deleted) trigger row by composite key.
GetTrigger(ctx context.Context, key TriggerNameKey) (*models.Trigger, error)
// GetTriggerRevision returns a specific immutable revision row.
GetTriggerRevision(ctx context.Context, project, domain, taskName, name string, revision uint64) (*models.TriggerRevision, error)
// ListTriggers returns the latest (non-deleted) trigger rows matching the input.
ListTriggers(ctx context.Context, input ListResourceInput) ([]*models.Trigger, error)
// ListTriggerRevisions returns revision history for a given trigger, ordered by revision DESC.
ListTriggerRevisions(ctx context.Context, project, domain, taskName, name string, input ListResourceInput) ([]*models.TriggerRevision, error)
// UpdateTriggers activates or deactivates the given triggers and appends revision rows.
UpdateTriggers(ctx context.Context, keys []TriggerNameKey, active bool) error
// DeleteTriggers soft-deletes the given triggers and appends revision rows.
DeleteTriggers(ctx context.Context, keys []TriggerNameKey) error
}
TriggerRepo manages the mutable triggers table and the append-only trigger_revisions table. Mirrors the Action (latest state) + ActionEvent (history) pattern used elsewhere in OSS.
Click to show internal directories.
Click to hide internal directories.