| 1 | import * as Data from "effect/Data"; |
| 2 | |
| 3 | /** |
| 4 | * Server-side failures worth another attempt: throttling and the 5xx |
| 5 | * statuses Google fronts return for load, rollout, and replica hiccups. |
| 6 | * Every distilled GCP operation carries these tags in its error union. |
| 7 | * |
| 8 | * NOT exported from `index.ts`. |
| 9 | */ |
| 10 | const TRANSIENT_TAGS = new Set([ |
| 11 | "TooManyRequests", |
| 12 | "InternalServerError", |
| 13 | "BadGateway", |
| 14 | "ServiceUnavailable", |
| 15 | "GatewayTimeout", |
| 16 | ]); |
| 17 | |
| 18 | export const isTransientGcpError = (error: { readonly _tag: string }) => |
| 19 | TRANSIENT_TAGS.has(error._tag); |
| 20 | |
| 21 | /** |
| 22 | * A delete call succeeded but the resource was still readable after the |
| 23 | * bounded wait-until-gone poll. |
| 24 | */ |
| 25 | export class DeleteNotConfirmed extends Data.TaggedError( |
| 26 | "GCP.DeleteNotConfirmed", |
| 27 | )<{ |
| 28 | resource: string; |
| 29 | }> {} |