Help us shape the future of Go! Take the 2026 Go Developer Survey

devproxy

package
v0.66.1 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package devproxy is the contract shared by cmd/desktop/devserver and cmd/desktop/devtools: where the development GitHub proxy listens, and how to tell whether one is already running there.

It exists because the proxy is a singleton by design (ADR devserver-github-proxy). devserver needs to know if it is a duplicate launch, and devtools needs to point a worktree's launch.env at the same address and fail loudly when nothing is listening. Duplicating either fact would let the two drift into a setup where the app is redirected at a port no proxy owns.

Index

Constants

View Source
const DefaultListen = "127.0.0.1:7777"

DefaultListen is the proxy's bind address when the config omits one. It is a fixed loopback port rather than an allocated one precisely because every instance has to find it without discovery.

View Source
const EnvAPIBase = "HIVE_DESKTOP_DEVELOPMENT_GITHUB_API_BASE"

EnvAPIBase names the desktop setting this package's address feeds. It is duplicated from cmd/desktop/internal/app/settings rather than imported because cmd/desktop/devserver must not depend on an app package for a string (ADR devserver-github-proxy: the app does not import devserver and devserver does not import the app), and both binaries need the name — devtools to read it, devserver to name it in the hint it prints at startup. cmd/desktop/devtools imports both packages and asserts the two spellings agree.

View Source
const HealthPath = "/_ctl/health"

HealthPath answers the "are you already running?" probe. It is deliberately cheaper than /_ctl/state, which builds a full overlay and scenario snapshot.

View Source
const RepoConfigPath = "cmd/desktop/devserver/devserver.yaml"

RepoConfigPath is the checked-in development config, relative to the repository root. Development configuration lives in the repo, not in a user's home directory: it is versioned with the code whose behaviour it simulates, and a fresh clone gets working scenarios with no setup step.

Variables

This section is empty.

Functions

func BaseURL

func BaseURL(listen string) string

BaseURL is the API base a desktop instance sets to route through a proxy listening at listen.

func ListenFromConfig

func ListenFromConfig(root string) string

ListenFromConfig reads the bind address out of the checked-in config at root, falling back to DefaultListen when the file is absent or declares no listen. The config is the single source of truth for the port, so a change there reaches launch.env without anyone editing two places.

Types

type Health

type Health struct {
	Devserver bool `json:"devserver"`
}

Health is the probe payload. The Devserver field is the marker that distinguishes our proxy from any other process holding the port — binding blindly over a stranger's listener would be a confusing way to fail.

type Status

type Status int

Status is what a probe found at an address.

const (
	// StatusAbsent means nothing is listening: this process may bind.
	StatusAbsent Status = iota
	// StatusRunning means our devserver already owns the address.
	StatusRunning
	// StatusForeign means something answered but is not devserver.
	StatusForeign
)

func Probe

func Probe(ctx context.Context, baseURL string) Status

Probe reports what is answering at baseURL. A dial failure is StatusAbsent rather than an error: "nothing there" is the normal case for both callers, and only a caller can say whether it is a problem.

Jump to

Keyboard shortcuts

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