| Safe Haskell | None |
|---|---|
| Language | GHC2021 |
Ecluse.Core.Server.Response
Description
Map policy and upstream outcomes to HTTP statuses. Artifact requests use one outcome, while packuments choose a status from the surviving versions. Ecosystem contracts own response bodies.
Synopsis
- data ServeDecision
- data Rejection = Rejection {}
- data RejectReason
- data Transience
- newtype RetryAfter = RetryAfter Int
- newtype RuleName = RuleName Text
- rejectUnavailable :: Transience -> Text -> ServeDecision
- serveDecisionOf :: RuleEvidence -> Decision -> ServeDecision
- data ArtifactStatus
- artifactStatus :: ServeDecision -> ArtifactStatus
- artifactHttpStatus :: ArtifactStatus -> Status
- data PackumentStatus
- packumentStatus :: [ServeDecision] -> PackumentStatus
- longestRetry :: [Maybe RetryAfter] -> Maybe RetryAfter
- data HelpMessage
- mkHelpMessage :: Text -> HelpMessage
- appendHelp :: Maybe HelpMessage -> Text -> Text
- data Refusal = Refusal {}
- mkRefusal :: Maybe HelpMessage -> Text -> Refusal
- renderRefusal :: Refusal -> Text
- refusalHelpBytes :: Refusal -> Maybe LByteString
Serve outcomes
data ServeDecision Source #
The outcome of deciding a request: serve it, or refuse it with a reason. Every client-facing reply renders one.
Constructors
| Admit | Serve the request (the |
| Reject Rejection | Refuse the request, with the reason and a client-facing message. |
Instances
| Show ServeDecision Source # | |
Defined in Ecluse.Core.Server.Response Methods showsPrec :: Int -> ServeDecision -> ShowS # show :: ServeDecision -> String # showList :: [ServeDecision] -> ShowS # | |
| Eq ServeDecision Source # | |
Defined in Ecluse.Core.Server.Response Methods (==) :: ServeDecision -> ServeDecision -> Bool # (/=) :: ServeDecision -> ServeDecision -> Bool # | |
A refusal: why the request was refused, and an intuitive message for the client.
Constructors
| Rejection | |
Fields
| |
data RejectReason Source #
Why a request was refused. A policy refusal is final for this request. An inability to decide carries a Transience for 503 or 500.
Constructors
| ByPolicy RuleName [Reason] | A rule denied the version (deny-by-default included): the deciding rule, and the reasons the decision gave. |
| Unavailable Transience | The version could not be vetted. Refuse it, with transience indicating whether a retry can help. |
| MissingIntegrity | A public artifact lacks a digest, so admission cannot verify its bytes. Trusted private artifacts are exempt. |
| BelowIntegrityFloor | A public artifact's strongest digest falls below the configured floor. Trusted private artifacts are exempt. |
| UpstreamInvalid | An upstream reply was invalid or unusable, such as a document that names a different package. |
Instances
| Show RejectReason Source # | |
Defined in Ecluse.Core.Server.Response Methods showsPrec :: Int -> RejectReason -> ShowS # show :: RejectReason -> String # showList :: [RejectReason] -> ShowS # | |
| Eq RejectReason Source # | |
Defined in Ecluse.Core.Server.Response | |
data Transience Source #
Whether a retry can help: a transient fault serves 503, and an internal or parse fault 500.
Constructors
| WillResolve (Maybe RetryAfter) | A retry may succeed after an outage, timeout, or open breaker. |
| WontResolve | Not expected to self-heal, so the request is a |
Instances
| Show Transience Source # | |
Defined in Ecluse.Core.Rules.Types Methods showsPrec :: Int -> Transience -> ShowS # show :: Transience -> String # showList :: [Transience] -> ShowS # | |
| Eq Transience Source # | |
Defined in Ecluse.Core.Rules.Types | |
newtype RetryAfter Source #
A Retry-After delay in whole seconds, never confused with another integer on its way to a header or a sweep's wait.
Constructors
| RetryAfter Int |
Instances
| Show RetryAfter Source # | |
Defined in Ecluse.Core.Fault Methods showsPrec :: Int -> RetryAfter -> ShowS # show :: RetryAfter -> String # showList :: [RetryAfter] -> ShowS # | |
| Eq RetryAfter Source # | |
Defined in Ecluse.Core.Fault | |
| Ord RetryAfter Source # | |
Defined in Ecluse.Core.Fault Methods compare :: RetryAfter -> RetryAfter -> Ordering # (<) :: RetryAfter -> RetryAfter -> Bool # (<=) :: RetryAfter -> RetryAfter -> Bool # (>) :: RetryAfter -> RetryAfter -> Bool # (>=) :: RetryAfter -> RetryAfter -> Bool # max :: RetryAfter -> RetryAfter -> RetryAfter # min :: RetryAfter -> RetryAfter -> RetryAfter # | |
The name of the rule that decided a refusal, for the audit trail and the denial body.
rejectUnavailable :: Transience -> Text -> ServeDecision Source #
Refuse a request that could not be decided. A caller states the Transience, and artifactStatus picks the status.
serveDecisionOf :: RuleEvidence -> Decision -> ServeDecision Source #
Project a rules Decision into a serve outcome. A version no rule could vet is refused as Unavailable.
Concrete-artifact status
data ArtifactStatus Source #
The HTTP status a concrete-artifact request renders to. PackumentStatus chooses a packument's over its survivors.
Constructors
| Ok |
|
| Forbidden |
|
| Unavailable' (Maybe RetryAfter) |
|
| ServerError |
|
| BadGateway |
|
| NotFound |
|
Instances
| Show ArtifactStatus Source # | |
Defined in Ecluse.Core.Server.Response Methods showsPrec :: Int -> ArtifactStatus -> ShowS # show :: ArtifactStatus -> String # showList :: [ArtifactStatus] -> ShowS # | |
| Eq ArtifactStatus Source # | |
Defined in Ecluse.Core.Server.Response Methods (==) :: ArtifactStatus -> ArtifactStatus -> Bool # (/=) :: ArtifactStatus -> ArtifactStatus -> Bool # | |
artifactStatus :: ServeDecision -> ArtifactStatus Source #
A serve outcome's concrete-artifact status: 503 only where it will resolve. It never yields NotFound.
artifactHttpStatus :: ArtifactStatus -> Status Source #
The HTTP status an ArtifactStatus renders as.
Packument status (over the merged survivor set)
data PackumentStatus Source #
The HTTP status a packument request renders to. A name no origin holds is decided before the merge.
Constructors
| PackumentOk |
|
| PackumentDenied | No version survived and every exclusion was a policy or integrity refusal. A listing answers
|
| PackumentForbidden |
|
| PackumentUnavailable (Maybe RetryAfter) |
|
| PackumentBadGateway |
|
| PackumentServerError |
|
Instances
| Show PackumentStatus Source # | |
Defined in Ecluse.Core.Server.Response Methods showsPrec :: Int -> PackumentStatus -> ShowS # show :: PackumentStatus -> String # showList :: [PackumentStatus] -> ShowS # | |
| Eq PackumentStatus Source # | |
Defined in Ecluse.Core.Server.Response Methods (==) :: PackumentStatus -> PackumentStatus -> Bool # (/=) :: PackumentStatus -> PackumentStatus -> Bool # | |
packumentStatus :: [ServeDecision] -> PackumentStatus Source #
With no survivor the most recoverable cause wins (503 over 502, as an origin may yet answer). An empty input is a 403.
longestRetry :: [Maybe RetryAfter] -> Maybe RetryAfter Source #
The longest suggested RetryAfter among transient causes, or Nothing when none suggested one.
Denial help text
data HelpMessage Source #
An operator-configured message appended to every denial. Stored trimmed, so an all-blank value contributes nothing.
Instances
| Show HelpMessage Source # | |
Defined in Ecluse.Core.Server.Response Methods showsPrec :: Int -> HelpMessage -> ShowS # show :: HelpMessage -> String # showList :: [HelpMessage] -> ShowS # | |
| Eq HelpMessage Source # | |
Defined in Ecluse.Core.Server.Response | |
mkHelpMessage :: Text -> HelpMessage Source #
Build a HelpMessage, trimming surrounding whitespace.
appendHelp :: Maybe HelpMessage -> Text -> Text Source #
Append a non-blank operator HelpMessage to a denial message, separated by a single space.
A refusal's two parts
A refusal's text in two parts, so an ecosystem without an envelope for both still keeps the help message.
Constructors
| Refusal | |
Fields
| |
mkRefusal :: Maybe HelpMessage -> Text -> Refusal Source #
Pair a decided reason with the mount's configured help message, if it has a non-blank one.
renderRefusal :: Refusal -> Text Source #
The refusal as one line: the reason, with the help message appended after a single space.
refusalHelpBytes :: Refusal -> Maybe LByteString Source #
The help message alone as body bytes, absent when none is configured.