pipelinetriggers

package
v0.3.0-rc.5 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2026 License: Apache-2.0 Imports: 16 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrPipelineTriggerNotFound indicates that the trigger does not exist in the requested environment.
	ErrPipelineTriggerNotFound = xerror.NotFound(xerror.PipelineTrigger)

	// ErrPipelineTriggerSlugTaken indicates that a trigger slug already exists in the requested environment.
	ErrPipelineTriggerSlugTaken = xerror.AlreadyExists(xerror.PipelineTrigger).Detail("pipeline trigger slug already exists")

	// ErrPipelineTriggerDependencyMissing indicates that trigger creation references a missing environment, pipeline, or version.
	ErrPipelineTriggerDependencyMissing = xerror.InvalidInput(xerror.PipelineTrigger).Detail("pipeline trigger dependency is missing")

	// ErrPipelineVersionNotFound indicates that a pinned pipeline version does not exist.
	ErrPipelineVersionNotFound = xerror.NotFound(xerror.PipelineVersion)

	// ErrPipelineVersionAmbiguous indicates that a pinned version hash prefix matched more than one version.
	ErrPipelineVersionAmbiguous = xerror.InvalidInput(xerror.PipelineVersion)
)

Functions

This section is empty.

Types

type ClaimedScheduleFire

type ClaimedScheduleFire struct {
	Resuming bool
	Trigger  DueScheduleTrigger
	Claim    ScheduleFireClaim
	FireSlug slug.Slug
}

ClaimedScheduleFire contains the trigger snapshot needed to execute one fire.

type CompletionDispatchRef

type CompletionDispatchRef struct {
	ID              int
	OrgSlug         slug.Slug
	ProjectSlug     slug.Slug
	EnvironmentSlug slug.Slug
	ExecutionArgs   []byte
	FailedRunSlug   slug.Slug
}

type CompletionEdge

type CompletionEdge struct {
	TriggerSlug  slug.Slug
	PipelineSlug slug.Slug
	Enabled      bool
	Config       model.PipelineTriggerCompletionConfig
}

type CreatePipelineTriggerParams

type CreatePipelineTriggerParams struct {
	Slug             slug.Slug
	Name             string
	Type             model.PipelineTriggerType
	Enabled          bool
	PipelineSlug     slug.Slug
	VersionPolicy    model.PipelineTriggerVersionPolicy
	RuntimeInputKeys []string
	RetryPolicy      model.PipelineTriggerRetryPolicy
	ScheduleConfig   *model.PipelineTriggerScheduleConfig
	CompletionConfig *model.PipelineTriggerCompletionConfig
	WebhookConfig    *model.PipelineTriggerWebhookConfig
	Actor            model.EventActor
}

CreatePipelineTriggerParams contains validated persistence input for a trigger.

type DelayedScheduleFire

type DelayedScheduleFire struct {
	OrgSlug, ProjectSlug, EnvironmentSlug, TriggerSlug, PipelineSlug slug.Slug
	TriggerRevision                                                  int64
	ScheduledFireAt, ActualFireAt                                    time.Time
}

DelayedScheduleFire is safe scope and timing evidence from an unfinished fire.

type DueScheduleTrigger

type DueScheduleTrigger struct {
	OrgSlug             slug.Slug
	ProjectSlug         slug.Slug
	EnvironmentSlug     slug.Slug
	TriggerSlug         slug.Slug
	TriggerRevision     int64
	Enabled             bool
	PipelineSlug        slug.Slug
	VersionPolicy       model.PipelineTriggerVersionPolicy
	RuntimeInputKeys    []string
	RetryPolicy         model.PipelineTriggerRetryPolicy
	ScheduleConfig      model.PipelineTriggerScheduleConfig
	TriggerCreatedAt    time.Time
	TriggerUpdatedAt    time.Time
	LastScheduledFireAt *time.Time
}

DueScheduleTrigger is the scheduler-facing projection of one enabled schedule trigger.

type PendingRunFinalization

type PendingRunFinalization struct {
	OrgSlug, ProjectSlug, EnvironmentSlug, TriggerSlug slug.Slug
	TriggerRevision                                    int64
	ScheduledAt                                        time.Time
	RetryAttemptSlug, ReceiverID, DeliveryID           string
	AttemptNumber                                      int
}

PendingRunFinalization retains only the exact queue identity of a terminal attempt whose source owner has not committed its completion/retry decision.

type PipelineTrigger

type PipelineTrigger struct {
	Slug             slug.Slug
	Name             string
	Type             model.PipelineTriggerType
	Enabled          bool
	Revision         int64
	EnvironmentSlug  slug.Slug
	PipelineSlug     slug.Slug
	VersionPolicy    model.PipelineTriggerVersionPolicy
	RuntimeInputKeys []string
	RetryPolicy      model.PipelineTriggerRetryPolicy
	ScheduleConfig   *model.PipelineTriggerScheduleConfig
	CompletionConfig *model.PipelineTriggerCompletionConfig
	WebhookConfig    *model.PipelineTriggerWebhookConfig
	CreatedBy        model.EventActor
	UpdatedBy        model.EventActor
	DisabledAt       *time.Time
	CreatedAt        time.Time
	UpdatedAt        time.Time
}

PipelineTrigger is the repository representation of a persisted trigger definition.

type Repository

type Repository interface {
	ListCompletionRunFinalizationsForSystem(context.Context, postgres.DBTX) ([]CompletionDispatchRef, error)
	FenceCompletionRetryDecision(context.Context, postgres.DBTX, slug.Slug, int) (time.Time, error)
	SaveCompletionRetryExecution(context.Context, postgres.DBTX, slug.Slug, int, slug.Slug, []byte) error
	DeferCompletionRunFinalization(context.Context, postgres.DBTX, slug.Slug, int, slug.Slug, string) error
	ListPendingCompletionsForSystem(context.Context, postgres.DBTX) ([]CompletionDispatchRef, error)
	ListCompletionRepairsForSystem(context.Context, postgres.DBTX) ([]CompletionDispatchRef, error)
	AcceptCompletionSnapshot(context.Context, postgres.DBTX, slug.Slug, int, slug.Slug, []byte) error
	DeferCompletionSnapshot(context.Context, postgres.DBTX, slug.Slug, int, string) error
	CompleteCompletionSnapshotsForSystem(context.Context, postgres.DBTX) error
	LoadCompletionSnapshot(context.Context, postgres.DBTX, slug.Slug, slug.Slug, slug.Slug, int) (*model.PipelineCompletionSnapshot, error)
	RefuseCompletionSnapshot(context.Context, postgres.DBTX, slug.Slug, int, string) error
	LockPipelineTriggerTopology(context.Context, postgres.DBTX, slug.Slug, slug.Slug, slug.Slug) (bool, error)
	ListPipelineCompletionEdges(context.Context, postgres.DBTX, slug.Slug, slug.Slug, slug.Slug) ([]CompletionEdge, error)
	ReconcileLogicalRunFinalizationsForSystem(context.Context, postgres.DBTX) error
	ListPendingRunFinalizationsForSystem(context.Context, postgres.DBTX) ([]PendingRunFinalization, error)
	ProjectEnvironmentEnabled(
		ctx context.Context,
		tx postgres.DBTX,
		orgSlug, projectSlug, environmentSlug slug.Slug,
	) (bool, error)
	PipelineExists(
		ctx context.Context,
		tx postgres.DBTX,
		orgSlug, projectSlug, pipelineSlug slug.Slug,
	) (bool, error)
	ResolvePinnedVersionHash(
		ctx context.Context,
		tx postgres.DBTX,
		orgSlug, projectSlug, pipelineSlug slug.Slug,
		specHash string,
	) (string, error)
	DeploymentExists(
		ctx context.Context,
		tx postgres.DBTX,
		orgSlug, projectSlug, environmentSlug, pipelineSlug slug.Slug,
	) (bool, error)
	CreatePipelineTrigger(
		ctx context.Context,
		tx postgres.DBTX,
		orgSlug, projectSlug, environmentSlug slug.Slug,
		params CreatePipelineTriggerParams,
	) (*PipelineTrigger, error)
	FindPipelineTriggerBySlug(
		ctx context.Context,
		tx postgres.DBTX,
		orgSlug, projectSlug, environmentSlug, triggerSlug slug.Slug,
	) (*PipelineTrigger, error)
	ListPipelineTriggers(
		ctx context.Context,
		tx postgres.DBTX,
		orgSlug, projectSlug, environmentSlug slug.Slug,
		req model.ListRequest,
	) ([]*PipelineTrigger, error)
	UpdatePipelineTrigger(
		ctx context.Context,
		tx postgres.DBTX,
		orgSlug, projectSlug, environmentSlug, triggerSlug slug.Slug,
		params UpdatePipelineTriggerParams,
	) (*PipelineTrigger, error)
	DeletePipelineTrigger(
		ctx context.Context,
		tx postgres.DBTX,
		orgSlug, projectSlug, environmentSlug, triggerSlug slug.Slug,
	) error
	ListDelayedScheduleFiresForSystem(context.Context, postgres.DBTX, time.Time) ([]DelayedScheduleFire, error)
	ListDueScheduleTriggersForSystem(
		ctx context.Context,
		tx postgres.DBTX,
	) ([]DueScheduleTrigger, error)
	ClaimScheduleFire(
		ctx context.Context,
		tx postgres.DBTX,
		claim ScheduleFireClaim,
	) (ScheduleFireClaimResult, error)
	LoadClaimedScheduleFire(
		ctx context.Context,
		tx postgres.DBTX,
		ref ScheduleFireExecutionRef,
	) (ClaimedScheduleFire, error)
	MarkScheduleFireRunning(
		ctx context.Context,
		tx postgres.DBTX,
		ref ScheduleFireExecutionRef,
	) error
	CompleteScheduleFire(
		ctx context.Context,
		tx postgres.DBTX,
		completion ScheduleFireCompletion,
	) error
	ListScheduleFiresForTrigger(
		ctx context.Context,
		tx postgres.DBTX,
		orgSlug, projectSlug, environmentSlug, triggerSlug slug.Slug,
		req model.ListRequest,
	) ([]ScheduleFireDiagnostic, error)
	RecordTriggerRetryAttempt(
		ctx context.Context,
		tx postgres.DBTX,
		record TriggerRetryAttemptRecord,
	) (TriggerRetryAttempt, error)
	ListTriggerRetryAttemptsForRun(
		ctx context.Context,
		tx postgres.DBTX,
		orgSlug, projectSlug, environmentSlug, runSlug slug.Slug,
	) ([]TriggerRetryAttemptDiagnostic, error)
	LoadTriggerRetryAttemptForExecution(
		ctx context.Context,
		tx postgres.DBTX,
		orgSlug, projectSlug, environmentSlug, attemptSlug slug.Slug,
	) (TriggerRetryAttempt, error)
	MarkTriggerRetryAttemptRunning(
		ctx context.Context,
		tx postgres.DBTX,
		orgSlug, projectSlug, environmentSlug, attemptSlug slug.Slug,
	) error
	CompleteTriggerRetryAttempt(
		ctx context.Context,
		tx postgres.DBTX,
		orgSlug, projectSlug, environmentSlug, attemptSlug slug.Slug,
		status model.PipelineTriggerRetryAttemptStatus,
		sourceEventSlug *slug.Slug,
		errorSummary *string,
	) error
}

Repository provides SQL-backed persistence for environment-scoped pipeline triggers.

func NewRepository

func NewRepository() Repository

NewRepository creates the SQLC-backed pipeline trigger repository.

type ScheduleFireClaim

type ScheduleFireClaim struct {
	OrgSlug         slug.Slug
	ProjectSlug     slug.Slug
	EnvironmentSlug slug.Slug
	TriggerSlug     slug.Slug
	TriggerRevision int64
	ScheduledFireAt time.Time
	ActualFireAt    time.Time
	MisfireResult   model.PipelineTriggerScheduleMisfireResult
}

ScheduleFireClaim contains the idempotency key for one scheduled trigger fire.

func (ScheduleFireClaim) FireSlug

func (c ScheduleFireClaim) FireSlug() slug.Slug

FireSlug returns the deterministic external slug for a scheduled fire claim.

type ScheduleFireClaimResult

type ScheduleFireClaimResult struct {
	Claimed  bool
	FireSlug slug.Slug
}

ScheduleFireClaimResult reports whether this dispatcher claimed the fire.

type ScheduleFireCompletion

type ScheduleFireCompletion struct {
	OrgSlug         slug.Slug
	ProjectSlug     slug.Slug
	EnvironmentSlug slug.Slug
	TriggerSlug     slug.Slug
	TriggerRevision int64
	ScheduledFireAt time.Time
	Status          string
	RunSlug         *string
	SourceEventSlug *slug.Slug
	ErrorSummary    *string
}

ScheduleFireCompletion stores the terminal diagnostic state for a claimed fire.

type ScheduleFireDiagnostic

type ScheduleFireDiagnostic struct {
	FireSlug        slug.Slug
	TriggerSlug     slug.Slug
	TriggerRevision int64
	PipelineSlug    slug.Slug
	ScheduledFireAt time.Time
	ActualFireAt    time.Time
	Status          model.PipelineScheduleFireStatus
	MisfireResult   model.PipelineTriggerScheduleMisfireResult
	RunSlug         *slug.Slug
	SourceEventSlug *slug.Slug
	ErrorSummary    *string
	CreatedAt       time.Time
	UpdatedAt       time.Time
}

ScheduleFireDiagnostic is the safe read projection for schedule-fire visibility surfaces.

type ScheduleFireExecutionRef

type ScheduleFireExecutionRef struct {
	OrgSlug         slug.Slug
	ProjectSlug     slug.Slug
	EnvironmentSlug slug.Slug
	TriggerSlug     slug.Slug
	TriggerRevision int64
	ScheduledFireAt time.Time
}

ScheduleFireExecutionRef durably identifies one claimed scheduled fire.

type TriggerRetryAttempt

type TriggerRetryAttempt struct {
	AttemptSlug             slug.Slug
	Status                  model.PipelineTriggerRetryAttemptStatus
	DecisionReason          string
	OrgSlug                 slug.Slug
	ProjectSlug             slug.Slug
	EnvironmentSlug         slug.Slug
	TriggerSlug             slug.Slug
	TriggerRevision         int64
	PipelineSlug            slug.Slug
	VersionPolicy           model.PipelineTriggerVersionPolicy
	PipelineVersionSpecHash string
	RuntimeInputKeys        []string
	RetryPolicy             model.PipelineTriggerRetryPolicy
	Source                  pipelinerun.RunSourceSummary
	RootRunSlug             slug.Slug
	RetryOfRunSlug          slug.Slug
	RunSlug                 slug.Slug
	AttemptNumber           int
	FailureKind             model.PipelineTriggerRetryFailureKind
	ScheduledAt             time.Time
	StartedAt               *time.Time
	CompletedAt             *time.Time
	ErrorSummary            *string
	CreatedAt               time.Time
}

TriggerRetryAttempt is the persisted retry attempt projection used by workers.

type TriggerRetryAttemptDiagnostic

type TriggerRetryAttemptDiagnostic struct {
	AttemptSlug     slug.Slug
	Status          model.PipelineTriggerRetryAttemptStatus
	DecisionReason  *string
	TriggerSlug     slug.Slug
	TriggerRevision int64
	PipelineSlug    slug.Slug
	RootRunSlug     slug.Slug
	RetryOfRunSlug  slug.Slug
	RunSlug         slug.Slug
	AttemptNumber   int
	FailureKind     *model.PipelineTriggerRetryFailureKind
	SourceEventSlug *slug.Slug
	ScheduledAt     time.Time
	EnqueuedAt      *time.Time
	StartedAt       *time.Time
	CompletedAt     *time.Time
	ErrorSummary    *string
	CreatedAt       time.Time
	UpdatedAt       time.Time
}

TriggerRetryAttemptDiagnostic is the safe read projection for retry visibility surfaces.

type TriggerRetryAttemptRecord

type TriggerRetryAttemptRecord struct {
	OrgSlug                 slug.Slug
	ProjectSlug             slug.Slug
	EnvironmentSlug         slug.Slug
	TriggerSlug             slug.Slug
	TriggerRevision         int64
	Status                  model.PipelineTriggerRetryAttemptStatus
	DecisionReason          string
	PipelineSlug            slug.Slug
	VersionPolicy           model.PipelineTriggerVersionPolicy
	PipelineVersionSpecHash string
	RuntimeInputKeys        []string
	RetryPolicy             model.PipelineTriggerRetryPolicy
	Source                  pipelinerun.RunSourceSummary
	RootRunSlug             slug.Slug
	RetryOfRunSlug          slug.Slug
	RunSlug                 slug.Slug
	AttemptNumber           int
	FailureKind             model.PipelineTriggerRetryFailureKind
	SourceEventSlug         *slug.Slug
	ScheduledAt             time.Time
}

TriggerRetryAttemptRecord contains the durable retry decision to persist.

func (TriggerRetryAttemptRecord) AttemptSlug

func (r TriggerRetryAttemptRecord) AttemptSlug() (slug.Slug, error)

AttemptSlug returns a bounded deterministic slug for the persisted retry decision.

type UpdatePipelineTriggerParams

type UpdatePipelineTriggerParams struct {
	Name             string
	Type             model.PipelineTriggerType
	Enabled          bool
	PipelineSlug     slug.Slug
	VersionPolicy    model.PipelineTriggerVersionPolicy
	RuntimeInputKeys []string
	RetryPolicy      model.PipelineTriggerRetryPolicy
	ScheduleConfig   *model.PipelineTriggerScheduleConfig
	CompletionConfig *model.PipelineTriggerCompletionConfig
	WebhookConfig    *model.PipelineTriggerWebhookConfig
	Actor            model.EventActor
}

UpdatePipelineTriggerParams contains validated full replacement input for a trigger.

Jump to

Keyboard shortcuts

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