aws

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2026 License: MIT Imports: 28 Imported by: 0

Documentation

Overview

Package aws provides AWS implementations of the application ports.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AWS

type AWS struct {
	S3                    *s3.Client
	SQS                   *sqs.Client
	DynamoDB              *dynamodb.Client
	SSM                   *ssm.Client
	FileConfigPath        string
	GlobalLimitsParameter string
	LedgerTable           string
	MaxReceiveCount       int
	LedgerRetentionDays   int
}

func New

func New(ctx context.Context, c config.Config) (*AWS, error)

func (*AWS) AcquireChunk

func (a *AWS) AcquireChunk(ctx context.Context, jobID, chunkID string) (f2e.AcquisitionResult, error)

AcquireChunk claims a PENDING chunk for execution, writing a fresh ownership token and bumping the attempt counter. It returns Acquired on a successful claim, AlreadyCompleted if the chunk is terminal, or Busy if another worker already holds it.

func (*AWS) Admit

func (a *AWS) Admit(ctx context.Context, receipt f2e.Receipt) (f2e.AcquisitionResult, error)

Admit binds a receipt to a job item in the RECEIVED state. jobId is the fileId, so a different SQS receipt for the same physical object identity links to the existing normal execution rather than creating a duplicate. It returns Acquired on first write, AlreadyCompleted if the job is terminal, or Busy if another execution owns it.

func (*AWS) BeginPlanning

func (a *AWS) BeginPlanning(ctx context.Context, jobID string) error

BeginPlanning moves a VALIDATING job into PLANNING.

func (*AWS) BeginValidation

func (a *AWS) BeginValidation(ctx context.Context, jobID string) error

BeginValidation moves a RECEIVED job into VALIDATING.

func (*AWS) CompleteChunk

func (a *AWS) CompleteChunk(ctx context.Context, result f2e.ChunkResult) error

func (*AWS) FailChunk

func (a *AWS) FailChunk(ctx context.Context, result f2e.ChunkResult) error

func (*AWS) GetJob

func (a *AWS) GetJob(ctx context.Context, jobID string) (JobSummary, error)

GetJob returns the operational summary for a specific job by its jobId.

func (*AWS) GetJobByReceiptID

func (a *AWS) GetJobByReceiptID(ctx context.Context, receiptID string) (JobSummary, error)

GetJobByReceiptID finds a job aggregate by its SQS receipt identifier. It queries the receipt link item (sk=RECEIPT#<receiptId>) to resolve the jobId, then reads the job aggregate.

func (*AWS) GetRange

func (a *AWS) GetRange(ctx context.Context, object f2e.ObjectIdentity, start, end int64) (io.ReadCloser, error)

func (*AWS) Head

func (a *AWS) Head(ctx context.Context, b, k string) (f2e.ObjectIdentity, error)

func (*AWS) HeadObject

func (a *AWS) HeadObject(ctx context.Context, object f2e.ObjectIdentity) (f2e.ObjectIdentity, error)

func (*AWS) LoadGlobalLimits

func (a *AWS) LoadGlobalLimits(ctx context.Context) (f2e.GlobalLimits, int64, string, error)

func (*AWS) MarkChunksScheduled

func (a *AWS) MarkChunksScheduled(ctx context.Context, chunks []f2e.ChunkJob) error

MarkChunksScheduled saves one durable checkpoint per confirmed SQS message. It deliberately does not change chunk status: a Worker still owns the PENDING -> RUNNING transition.

func (*AWS) MarkIntentDelivered

func (a *AWS) MarkIntentDelivered(ctx context.Context, jobID string, version int64) error

MarkIntentDelivered removes the pending marker after SQS confirms the send. It is called by the Worker only after SQS confirms the send; a crash between send and mark may duplicate delivery, which consumers handle via the stable, deterministic eventId.

func (*AWS) MarkScheduled

func (a *AWS) MarkScheduled(ctx context.Context, jobIDs []string) error

func (*AWS) MarkSchedulingFailed

func (a *AWS) MarkSchedulingFailed(ctx context.Context, jobIDs []string, message string) error

func (*AWS) OpenChunkRange

func (a *AWS) OpenChunkRange(ctx context.Context, job f2e.ChunkJob, start, end int64) (io.ReadCloser, error)

OpenChunkRange implements port.SourceResolver. It uses the pre-signed URL when present, falling back to S3 SDK access via bucket/key.

func (*AWS) Plan

func (a *AWS) Plan(ctx context.Context, plan f2e.JobPlan, chunks []f2e.ChunkJob) error

func (*AWS) QueryJobsByStatus

func (a *AWS) QueryJobsByStatus(ctx context.Context, status f2e.JobStatus, after, before string, limit int) ([]JobSummary, error)

QueryJobsByStatus returns jobs in a given status ordered by updatedAt. Use after and before to restrict the time window; both are RFC3339 strings. A limit of 0 defaults to 100. Non-terminal statuses with old timestamps are candidates for the stuck-job reconciler.

func (*AWS) ReconcileCompletion

func (a *AWS) ReconcileCompletion(ctx context.Context, jobID string) (*f2e.CompletionIntent, error)

ReconcileCompletion is the Worker-owned completion outbox. The terminal job mutation and its intent are committed in one DynamoDB transaction. A competing Worker reads the same intent, so retries cannot mint another eventId.

func (*AWS) RejectJob

func (a *AWS) RejectJob(ctx context.Context, jobID string, rejection f2e.Rejection) error

RejectJob moves a RECEIVED or VALIDATING job into REJECTED with a reason.

func (*AWS) Replay

func (a *AWS) Replay(ctx context.Context, sourceJobID, newJobID string, chunkIDs []string) ([]f2e.ChunkJob, error)

func (*AWS) ResolvePrefixConfiguration

func (a *AWS) ResolvePrefixConfiguration(ctx context.Context, bucket, key string) (f2e.PrefixConfiguration, f2e.ConfigurationSnapshot, error)

ResolvePrefixConfiguration selects the most specific SSM configuration whose bucket and key prefix match the received S3 object. It returns the configuration together with an immutable provenance snapshot.

func (*AWS) Send

func (a *AWS) Send(ctx context.Context, url string, messages []port.OutboundMessage) ([]int, error)

func (*AWS) StartChunk

func (a *AWS) StartChunk(ctx context.Context, jobID, chunkID string, attempt int) error

func (*AWS) StuckJobs

func (a *AWS) StuckJobs(ctx context.Context, stuckThreshold time.Duration, limit int) ([]JobSummary, error)

StuckJobs returns non-terminal jobs whose updatedAt is older than the given threshold. These are candidates for operator review; the reconciler does not automatically replay without explicit human confirmation.

A job is considered stuck if:

  • its status is one of RECEIVED, VALIDATING, PLANNING, or PROCESSING
  • its updatedAt timestamp has not advanced for at least stuckThreshold

func (*AWS) UnscheduledChunks

func (a *AWS) UnscheduledChunks(ctx context.Context, jobID string) ([]f2e.ChunkJob, error)

type JobSummary

type JobSummary struct {
	JobID       string        `json:"jobId"`
	FileID      string        `json:"fileId"`
	ReceiptID   string        `json:"receiptId,omitempty"`
	Status      f2e.JobStatus `json:"status"`
	Environment string        `json:"environment,omitempty"`
	CreatedAt   string        `json:"createdAt,omitempty"`
	UpdatedAt   string        `json:"updatedAt,omitempty"`
	// TerminalAt is the time the job reached a terminal state; empty for active jobs.
	TerminalAt string `json:"terminalAt,omitempty"`
	// Result qualifies a COMPLETED job (SUCCESS or WITH_REJECTIONS).
	Result f2e.JobResult `json:"result,omitempty"`
	// StuckSince is populated by StuckJobs and indicates how long the job has
	// been without a state transition.
	StuckSince *time.Duration `json:"stuckSince,omitempty"`
}

JobSummary is the operational view of a job returned by query operations. It is intentionally minimal — internal execution details and chunk lists are not included so the query path stays fast.

type PresignedCredentialError

type PresignedCredentialError struct{ StatusCode int }

func (PresignedCredentialError) Error

func (e PresignedCredentialError) Error() string

func (PresignedCredentialError) Transient

func (PresignedCredentialError) Transient() bool

Jump to

Keyboard shortcuts

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