coretransport

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2026 License: MIT Imports: 11 Imported by: ? 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 coretransport hands the surface requests Compa's chat client makes to an llmgw-core provider. Transport is an http.RoundTripper: it reads the surface from the request path and the model and stream flag from the body, calls the provider's Invoke or Stream, and turns a successful answer back into an HTTP response - a JSON body or an SSE body built from the provider's frames.

A failure is never turned into an HTTP error response. RoundTrip returns the provider's own error, a classified core error that carries its routing metadata (core.ClassifyError), and a stream that fails later fails its body's Read with that error. The client unwraps the *url.Error http.Client adds, so errors.As finds the core error. Once the request's context ends, the error is the context's, so cancellation stays distinct from a provider failure.

Index

Constants

View Source
const BaseURL = "http://core.invalid/v1"

BaseURL is the placeholder base the chat client addresses: the transport keeps only the request path's surface.

Variables

This section is empty.

Functions

func Client

func Client(t *Transport) *http.Client

Client returns an HTTP client that sends every request through t. It has no timeout of its own: the provider's HTTP client bounds each request.

Types

type CredentialSource

type CredentialSource func(ctx context.Context) (*core.Credential, error)

CredentialSource returns the credential for one request, or nil for a provider that needs none. It runs per request, so a refreshable credential is always current.

func StaticCredential

func StaticCredential(credential *core.Credential) CredentialSource

StaticCredential returns a source for a credential that never changes. A nil credential yields none.

type Transport

type Transport struct {
	// Provider serves the requests.
	Provider core.Provider
	// Credential returns each request's credential. Nil sends none.
	Credential CredentialSource
}

Transport sends surface requests to one core provider.

func (*Transport) RoundTrip

func (t *Transport) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip performs req's surface operation on the provider.

Jump to

Keyboard shortcuts

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