mocklimits

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2026 License: MIT Imports: 6 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 mocklimits defines deterministic limits for mock provider behavior.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BaseURL

func BaseURL(addr string) string

BaseURL converts a listen address into the client-facing base URL.

func Handler

func Handler(options Options) http.Handler

Handler returns an Anthropic-compatible HTTP handler with deterministic rate limiting behavior.

func RenderText

func RenderText(out io.Writer, report Report)

RenderText writes a human-readable mock server report.

Types

type Options

type Options struct {
	Addr         string
	Failures     int
	RetryAfterMS int
	Text         string
}

Options configures the local mock rate-limit server.

func Normalize

func Normalize(options Options) Options

Normalize fills defaults and clamps invalid option values.

type Report

type Report struct {
	Kind         string   `json:"kind"`
	Action       string   `json:"action"`
	Status       string   `json:"status"`
	Addr         string   `json:"addr"`
	BaseURL      string   `json:"base_url"`
	Failures     int      `json:"failures"`
	RetryAfterMS int      `json:"retry_after_ms"`
	Text         string   `json:"text"`
	Endpoint     string   `json:"endpoint"`
	Messages     []string `json:"messages,omitempty"`
}

Report describes the mock server endpoint and rate-limit behavior.

func BuildReport

func BuildReport(action string, options Options) Report

BuildReport returns a user-facing description of the mock server setup.

Jump to

Keyboard shortcuts

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