sourcestub

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

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