httputil

package
v1.121.0 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package httputil provides shared HTTP clients for cloud pricing ingestion.

The default net/http client has no timeout, so a hung or unreachable provider pricing endpoint can block pricing refresh indefinitely. These helpers return clients with sensible timeouts. They are shared and reused so a new connection pool is not created on every pricing fetch.

Index

Constants

View Source
const PricingTimeout = 30 * time.Second

PricingTimeout is applied to pricing HTTP requests. For the bounded client it caps the whole request; for the streaming client it caps the wait for response headers only (not the body read).

Variables

This section is empty.

Functions

func BoundedClient

func BoundedClient() *http.Client

BoundedClient returns a shared http.Client with a total request timeout, suitable for small or bounded pricing API responses.

func StreamingClient

func StreamingClient() *http.Client

StreamingClient returns a shared http.Client for large pricing downloads (for example the AWS pricing file or the Azure price sheet). It bounds the connect, TLS handshake, and response-header wait, but not the total body read, so a legitimately large or slow download is not truncated while a hung endpoint is still abandoned.

func StreamingGet

func StreamingGet(ctx context.Context, url string) (*http.Response, error)

StreamingGet issues a GET for a large download using the streaming client and the caller's context, so the request is cancelable. It centralizes the context-aware request construction shared by the large-download paths (the AWS pricing file and the Azure price sheet). Callers without a context of their own can pass context.Background().

Types

This section is empty.

Jump to

Keyboard shortcuts

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