mocklimits

package
v0.1.0 Latest Latest
Warning

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

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

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