sourcestub

package
v0.4.2-rc.2 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2026 License: Apache-2.0 Imports: 7 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 sourcestub provides a small OpenAI-shaped service for source-routing tests. It models a direct service, not a router with serving lanes.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Request

type Request struct {
	Method string
	Path   string
	Host   string
	Bearer string
	Agent  string
	Body   []byte
}

Request is one request observed by the service.

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server is a switchable fake direct model service.

func New

func New(models ...string) *Server

New starts a service that publishes models and answers completions.

func (*Server) Close

func (s *Server) Close()

Close shuts down the service.

func (*Server) Hang

func (s *Server) Hang(delay time.Duration)

Hang delays both routes long enough for a caller's timeout to fire.

func (*Server) Healthy

func (s *Server) Healthy()

Healthy clears a staged refusal or delay.

func (*Server) Listingless

func (s *Server) Listingless()

Listingless makes only GET /models answer 404. Completions remain healthy, which models vendors whose key can be proved only by a one-token call.

func (*Server) Refuse

func (s *Server) Refuse(status int, body string)

Refuse makes both routes answer with the chosen status and body.

func (*Server) RefuseCompletion

func (s *Server) RefuseCompletion(status int, body string)

RefuseCompletion leaves the listing healthy and refuses only generation. It models an authenticated key whose account cannot fund a billable call.

func (*Server) Requests

func (s *Server) Requests() []Request

Requests returns a copy of every request in arrival order.

func (*Server) URL

func (s *Server) URL() string

URL is the OpenAI-compatible base URL.

Jump to

Keyboard shortcuts

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