channel

package
v0.16.2 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2026 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Overview

Package channel provides one synthetic catalog channel for application tests. The channel runs on a local test server, so an application test exercises the real pull path and reaches no public network.

Index

Constants

View Source
const (
	// ConfiguredEnvironment names the credential of the eligible provider. A
	// test sets it to a placeholder that reaches only the local test server.
	ConfiguredEnvironment = "STARMAP_TEST_CONFIGURED_API_KEY"

	// AbsentEnvironment names a credential that no test sets. The provider that
	// needs it must send no request.
	AbsentEnvironment = "STARMAP_TEST_ABSENT_API_KEY"

	// ConfiguredProvider is the provider that holds a credential.
	ConfiguredProvider catalogs.ProviderID = "provider-configured"

	// UnconfiguredProvider is the provider that holds none.
	UnconfiguredProvider catalogs.ProviderID = "provider-unconfigured"

	// ObservedModel is the model slug that the channel and the provider share.
	ObservedModel = "model-observed"

	// AuthorID owns the canonical authored model of the channel.
	AuthorID catalogs.AuthorID = "test-author"

	// GenerationID names the one generation that the channel publishes.
	GenerationID = "synthetic-1"
)

Variables

This section is empty.

Functions

func Provider

func Provider(
	id catalogs.ProviderID,
	endpoint, environment string,
) catalogs.Provider

Provider returns one OpenAI-compatible provider that needs the named environment credential.

Types

type Upstream

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

Upstream is the local test server that publishes one synthetic channel and answers one provider model request. It is also the source that reads that channel, so a test injects it with runtime.WithSource.

func Start

func Start() (*Upstream, error)

Start builds the synthetic catalog and starts the local test server.

func (*Upstream) ChannelReads

func (u *Upstream) ChannelReads() int64

ChannelReads counts the channel reads that the runtime made.

func (*Upstream) Close

func (u *Upstream) Close()

Close stops the local test server. A test calls it to simulate an outage.

func (*Upstream) Identity

func (u *Upstream) Identity() string

Identity names the source without an address or a credential.

func (*Upstream) ModelReads

func (u *Upstream) ModelReads() int64

ModelReads counts the provider model requests that reached the server.

func (*Upstream) Read

func (u *Upstream) Read(ctx context.Context) (runtime.SourceRead, error)

Read checks the channel and returns the generation on the first change. A later read reports no change, so the runtime keeps its durable generation.

func (*Upstream) URL

func (u *Upstream) URL() string

URL returns the base address of the local test server.

Jump to

Keyboard shortcuts

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