requestconfig

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package requestconfig holds the resolved per-request configuration. It lives in internal/ so the option package can mutate it and the bird package can read it without an import cycle between them.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Attempt

type Attempt func(ctx context.Context, idempotencyKey string) (*http.Response, error)

Attempt performs one network round-trip with the per-attempt context and the idempotency key to set as a header.

type Config

type Config struct {
	BaseURL        string
	APIKey         string
	Region         string
	APIVersion     string
	HTTPClient     *http.Client
	MaxRetries     int
	Timeout        time.Duration
	IdempotencyKey string
	WebhookSecret  string
	Header         http.Header
	ResponseInto   *Response
	EmailDefaults  EmailDefaults
	// Sealed is set on the per-call config so construction-only options
	// (WithBaseURL/WithAPIKey/WithHTTPClient) can reject being applied per call.
	Sealed bool
}

Config is the settings for a single API call. Client options seed it at construction; per-call options Clone it and override individual fields.

BaseURL, APIKey, Region, and HTTPClient take effect at client construction only — the underlying HTTP client is built once. The remaining fields are honored per call.

func (Config) Clone

func (c Config) Clone() Config

Clone returns a copy safe to mutate with per-call options. The Header map is deep-copied; ResponseInto stays a shared pointer so the call can write into the caller's Response.

func (Config) Execute

func (cfg Config) Execute(ctx context.Context, mutation bool, call Attempt) ([]byte, error)

Execute runs the request lifecycle: for a mutation, a single idempotency key generated once and reused across attempts; a per-attempt timeout; and retries of transient failures with jittered backoff honoring Retry-After. It returns the drained 2xx body, or a typed *apierror error, and writes transport metadata to cfg.ResponseInto when set.

type EmailDefaults

type EmailDefaults struct {
	From        string
	ReplyTo     []string
	Category    oapi.EmailMessageCategory
	TrackOpens  *bool
	TrackClicks *bool
	Headers     map[string]string
	Tags        []oapi.Tag
	Metadata    map[string]interface{}
}

EmailDefaults are values applied to an email send when the per-send params leave the corresponding field unset. Re-exported as bird.EmailDefaults.

type Response

type Response struct {
	Status    int
	Header    http.Header
	RequestID string
}

Response is the transport metadata for one call, populated when the caller passes option.WithResponseInto. Re-exported as bird.Response.

Jump to

Keyboard shortcuts

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