pipelineschedulesvc

package
v0.4.0-linux-arm64 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2026 License: Apache-2.0 Imports: 24 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

This section is empty.

Functions

This section is empty.

Types

type DispatchResult

type DispatchResult struct {
	Scanned            int
	Claimed            int
	Enqueued           int
	SkippedInvalid     int
	SkippedDisabled    int
	SkippedMisfire     int
	AlreadyClaimed     int
	PreflightsEnqueued int
}

DispatchResult summarizes one scheduler scan for worker diagnostics and tests.

type DueScheduleTrigger

type DueScheduleTrigger = pipelinetriggers.DueScheduleTrigger

type NotificationProducer

type NotificationProducer = notificationsvc.CandidateProducer

NotificationProducer creates generic notification candidates for scheduler observations.

type Option

type Option func(*Service)

Option customizes optional scheduler integrations.

func WithNotificationProducer

func WithNotificationProducer(producer NotificationProducer) Option

WithNotificationProducer emits generic notification candidates for terminal retry decisions.

func WithPreflightServices

func WithPreflightServices(pipelines preflightPipelineService, sources preflightSourceService) Option

type PipelineExecutor

type PipelineExecutor interface {
	FailUnadmittedRun(context.Context, slug.Slug, slug.Slug, slug.Slug, slug.Slug) error
	ReconcileInterruptedRuns(context.Context, time.Time) error
	AcceptQueuedRun(context.Context, slug.Slug, slug.Slug, slug.Slug, slug.Slug, slug.Slug, pipelinerun.RunSourceSummary, time.Time, int64) error
	EnsureQueuedTriggerRun(context.Context, slug.Slug, slug.Slug, slug.Slug, slug.Slug, slug.Slug, pipelinerun.RunSourceSummary, time.Time, int64) error
	StartQueuedRun(context.Context, slug.Slug, slug.Slug, slug.Slug, slug.Slug, time.Time) error
	GetRun(context.Context, slug.Slug, slug.Slug, slug.Slug, string) (*pipelinesvc.PipelineRunDetail, error)
	Execute(
		ctx context.Context,
		orgSlug, projectSlug, environmentSlug, pipelineSlug slug.Slug,
		runSlug *slug.Slug,
		protectedEnvironmentConfirmation *slug.Slug,
		actor model.EventActor,
		source pipelinerun.RunSourceSummary,
		runtimeInput map[string]any,
	) (*pipelinesvc.PipelineRunDetail, error)
	ExecuteVersion(
		ctx context.Context,
		orgSlug, projectSlug, environmentSlug, pipelineSlug slug.Slug,
		specHash string,
		runSlug *slug.Slug,
		protectedEnvironmentConfirmation *slug.Slug,
		actor model.EventActor,
		source pipelinerun.RunSourceSummary,
		runtimeInput map[string]any,
	) (*pipelinesvc.PipelineRunDetail, error)
}

PipelineExecutor is the existing pipeline run entrypoint used by the scheduler.

type PipelineRetryProducer

type PipelineRetryProducer interface {
	EnqueueTriggerRetryExecution(
		ctx context.Context,
		tx postgres.DBTX,
		args jobs.PipelineTriggerRetryExecutionArgs,
	) (queue.QueuedJob, error)
}

PipelineRetryProducer enqueues one trigger retry attempt into River.

type Repository

type Repository interface {
	ReconcileLogicalRunFinalizationsForSystem(context.Context, postgres.DBTX) error
	ListPendingRunFinalizationsForSystem(context.Context, postgres.DBTX) ([]pipelinetriggers.PendingRunFinalization, error)
	ListDelayedScheduleFiresForSystem(context.Context, postgres.DBTX, time.Time) ([]pipelinetriggers.DelayedScheduleFire, error)
	ListDueScheduleTriggersForSystem(
		ctx context.Context,
		tx postgres.DBTX,
	) ([]DueScheduleTrigger, error)
	ClaimSchedulePreflight(context.Context, postgres.DBTX, ScheduleFireExecutionRef, time.Time) (bool, error)
	LoadPendingSchedulePreflight(context.Context, postgres.DBTX, ScheduleFireExecutionRef) (*pipelinetriggers.PendingSchedulePreflight, error)
	SaveSchedulePreflight(context.Context, postgres.DBTX, ScheduleFireExecutionRef, pipelinetriggers.SchedulePreflightProgress) 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
	RecordTriggerRetryAttempt(
		ctx context.Context,
		tx postgres.DBTX,
		record TriggerRetryAttemptRecord,
	) (TriggerRetryAttempt, 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 defines the persistence operations required by schedule dispatch.

type RetryDecisionInput

type RetryDecisionInput struct {
	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
	FailedRun               *pipelinesvc.PipelineRunDetail
	ExecutionError          error
	BaseAt                  time.Time
	ElapsedBaseAt           time.Time
	RetryRandom             func(int64) int64
}

RetryDecisionInput combines a captured policy with authoritative failed-run evidence.

type ScheduleFireClaim

type ScheduleFireClaim = pipelinetriggers.ScheduleFireClaim

type ScheduleFireProducer

type ScheduleFireProducer interface {
	EnqueueRunFinalization(context.Context, postgres.DBTX, queue.JobArgs) (queue.QueuedJob, error)
	EnqueueSchedulePreflight(context.Context, postgres.DBTX, jobs.PipelineSchedulePreflightArgs) (queue.QueuedJob, error)
	EnqueueScheduleFireExecution(
		ctx context.Context,
		tx postgres.DBTX,
		args jobs.PipelineScheduleFireExecutionArgs,
	) (queue.QueuedJob, error)
}

ScheduleFireProducer enqueues one claimed schedule fire into River.

type Service

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

Service dispatches persisted schedule triggers into pipeline runs.

func New

func New(
	txm postgres.TransactionManager,
	repo Repository,
	executor PipelineExecutor,
	producer ScheduleFireProducer,
	retryProducer PipelineRetryProducer,
	opts ...Option,
) *Service

New creates a schedule dispatcher using the repository and existing pipeline executor. Pass nil retryProducer only for callers that do not enqueue trigger retry attempts.

func (*Service) DispatchDueSchedules

func (s *Service) DispatchDueSchedules(ctx context.Context, now time.Time) (DispatchResult, error)

DispatchDueSchedules claims due schedule fires and enqueues one execution job per claimed fire.

func (*Service) ExecuteClaimedScheduleFire

func (s *Service) ExecuteClaimedScheduleFire(
	ctx context.Context,
	args jobs.PipelineScheduleFireExecutionArgs,
) error

ExecuteClaimedScheduleFire executes one already-claimed schedule fire and records completion.

func (*Service) ExecuteSchedulePreflight

func (s *Service) ExecuteSchedulePreflight(ctx context.Context, args jobs.PipelineSchedulePreflightArgs) (bool, error)

ExecuteSchedulePreflight returns true when the worker should wait for schema imports.

func (*Service) ExecuteTriggerRetryAttempt

func (s *Service) ExecuteTriggerRetryAttempt(
	ctx context.Context,
	args jobs.PipelineTriggerRetryExecutionArgs,
) error

ExecuteTriggerRetryAttempt executes one queued retry attempt and records the terminal result.

type TriggerRetryAttemptRecord

type TriggerRetryAttemptRecord = pipelinetriggers.TriggerRetryAttemptRecord

func BuildRetryAttempt

func BuildRetryAttempt(input RetryDecisionInput) (TriggerRetryAttemptRecord, bool, error)

BuildRetryAttempt converts one failed run into a durable retry decision.

Jump to

Keyboard shortcuts

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