| Safe Haskell | None |
|---|---|
| Language | GHC2021 |
Ecluse.Queue.Sqs
Description
The AWS SQS backend behind the MirrorQueue handle.
Maps the handle's receive → process → ack shape onto SQS:
enqueue→SendMessage(theMirrorJobencoded as the message body),receive→ one long-pollReceiveMessage(a batch,[]on an empty poll),ack→DeleteMessage(the message is gone, never redelivered),extendVisibility→ChangeMessageVisibility(hold a long publish).
The provider differences SQS embodies — the visibility timeout, the long-poll
window, the batch limit — are SqsConfig knobs with sane defaults, and the SQS
receipt handle is carried opaquely in a ReceiptHandle (via mkReceiptHandle),
so none of it leaks past the handle. Retry is "don't ack": a job whose
processing fails is simply not acked, and SQS redelivers it once the visibility
timeout lapses; persistent failures fall to the queue's native dead-letter
(max-receive-count), so there is no nack (see Ecluse.Queue).
The amazonka Env is built once at newSqsQueue and captured by the
handle's closures, so the backend's state never reaches the proxy's Env/App
(see docs/architecture/technology-stack.md → "Key Decisions"). The
MirrorJob wire mapping is a plain JSON object, decoded on receive; a body that
fails to parse is dropped rather than yielded as a partial, so — like any message
left unprocessed — it is not acked and SQS redelivers it, ultimately to the
dead-letter queue.
The SQS queue is a trusted, operator-declared destination (the configured queue
URL, or an endpoint override): like the OTLP telemetry endpoint (see
Ecluse.Telemetry.Resolve), it is reached through amazonka's own client and is
not subject to the data-plane egress controls (the host allowlist, the
internal-range block, or the resolved-IP recheck of Ecluse.Security.Egress), which
guard only untrusted package downloads — never a destination the operator configured.
Synopsis
- data SqsConfig = SqsConfig {}
- data SqsEndpoint = SqsEndpoint {}
- defaultSqsConfig :: Text -> Text -> SqsConfig
- newSqsQueue :: SqsConfig -> IO MirrorQueue
- encodeJob :: MirrorJob -> Text
- decodeJob :: Text -> Either Text MirrorJob
Configuration
What the SQS backend needs. The batch size, long-poll window, and visibility
timeout are provider knobs (see Ecluse.Queue) with defaults in
defaultSqsConfig.
Constructors
| SqsConfig | |
Fields
| |
data SqsEndpoint Source #
Where an SQS-compatible endpoint lives, for pointing the backend at a
non-default host: a local emulator (ministack) in tests, or a VPC endpoint. A
Nothing sqsEndpoint uses amazonka's default resolution and the ambient AWS
credential chain; an override needs explicit credentials because an emulator is
off that chain.
Constructors
| SqsEndpoint | |
Fields
| |
Instances
| Show SqsEndpoint Source # | |
Defined in Ecluse.Queue.Sqs Methods showsPrec :: Int -> SqsEndpoint -> ShowS # show :: SqsEndpoint -> String # showList :: [SqsEndpoint] -> ShowS # | |
| Eq SqsEndpoint Source # | |
Defined in Ecluse.Queue.Sqs | |
defaultSqsConfig :: Text -> Text -> SqsConfig Source #
A SqsConfig for a queue URL and region with the provider knobs at sane
defaults: a full batch of 10, the maximum 20-second long poll, and a 30-second
visibility timeout. Override the record fields to tune them, or set sqsEndpoint
to target an emulator.
The backend
newSqsQueue :: SqsConfig -> IO MirrorQueue Source #
Build an SQS-backed MirrorQueue. The amazonka Env is constructed
once here — region-scoped, and pointed at sqsEndpoint with its throwaway
credentials when one is given, otherwise discovering the ambient AWS credential
chain — and captured by the returned handle's closures.
Job wire mapping
encodeJob :: MirrorJob -> Text Source #
Encode a MirrorJob as the JSON text of an SQS message body. The inverse of
decodeJob: the package identity is split into its ecosystem, optional scope, and
bare name so it round-trips through mkPackageName, and the version keeps its raw
string. The serve-time-admitted artifact descriptor (jobArtifact) — the filename,
the integrity digests, and the declared size — round-trips as a nested object so the
worker has the digest to verify the fetched bytes against and the inputs to assemble
the publish document.