transport

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2026 License: MIT Imports: 9 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package transport — обвязка http.Client для API cloud.ru: повтор чтения при временном сбое, перевыпуск токена на 401, предел тела ответа и тело для ответов-ошибок без тела. Команды о ней не знают.

Index

Constants

View Source
const DefaultMaxBody int64 = 64 << 20

DefaultMaxBody — предел тела ответа. Самый большой список (1000 элементов страницы IAM) — сотни килобайт; больше — сбой шлюза или не тот адрес.

Variables

View Source
var DefaultRetryDelays = []time.Duration{2 * time.Second, 5 * time.Second, 10 * time.Second}

DefaultRetryDelays — паузы между повторами GET: 14.10 ~00:35 API Redis полчаса отвечал 403 «failed to verify project access», и прогон потерял 9 шагов из 21.

Functions

func New

New собирает цепочку: перевыпуск на 401 → повтор GET → тело для ошибок → предел тела → base. Перевыпуск снаружи повтора: отказ IAM не временный сбой, повтор GET снова пошёл бы в IAM.

Types

type Options

type Options struct {
	// Refresh перевыпускает токен после 401; nil — без перевыпуска.
	Refresh func(ctx context.Context) (string, error)
	// RetryDelays — паузы между повторами GET, их число — число повторов; nil — DefaultRetryDelays.
	RetryDelays []time.Duration
	// MaxBody — предел тела ответа в байтах; 0 — DefaultMaxBody.
	MaxBody int64
	// EmptyBodyHint — текст для ответа-ошибки без тела и без grpc-message.
	EmptyBodyHint func(code int) string
}

Options — настройки New; нулевые поля берут значения по умолчанию.

Jump to

Keyboard shortcuts

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