pgnoop

package
v6.3.2 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2026 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Overview

Package pgnoop manages the external pg-noop blackhole server binary used by the baseline command: resolving it from an embedded copy, the local cache, or the pinned GitHub release, and running it for the duration of a run.

Index

Constants

View Source
const Version = "v0.2.0"

Version is the pg-noop release stroppy pins. Bump together with release.sha256 and the asset mapping below when upgrading.

Variables

View Source
var ErrNoServerBinary = errors.New("pgnoop server binary unavailable")

ErrNoServerBinary reports that no binary source is available and what to do.

View Source
var ErrServerNotReady = errors.New("pgnoop: server did not become ready")

ErrServerNotReady reports that the server neither printed its listening line nor accepted connections within the readiness window.

View Source
var ErrUnknownDigest = errors.New("pgnoop: no pinned digest for asset")

ErrUnknownDigest is returned when a pinned asset has no compiled-in digest.

View Source
var ErrUnsupportedPlatform = errors.New("pgnoop: no release asset for this platform")

ErrUnsupportedPlatform is returned when no pg-noop release asset exists for the host platform.

Functions

func AssetDigest

func AssetDigest(asset string) (string, error)

AssetDigest returns the pinned sha256 hex digest for a release asset.

func AssetName

func AssetName(goos, goarch string) (string, error)

AssetName returns the release asset for a GOOS/GOARCH pair.

func CachePath

func CachePath() (string, error)

CachePath returns ~/.stroppy/bin/pg-noop/<version>/<os>-<arch>/pgnoop for the host.

func EmbeddedBinary

func EmbeddedBinary() []byte

EmbeddedBinary returns the server binary compiled into stroppy by CI release builds (build tag pgnoop_embed), or nil for plain builds.

func ExtractBinary

func ExtractBinary(tarball []byte) ([]byte, error)

ExtractBinary reads a pg-noop release tarball (tar.xz) and returns the raw server binary. The tarball wraps the binary in a per-target directory.

func HostTarget

func HostTarget() string

HostTarget describes the host platform for reports and diagnostics.

func ReleaseURL

func ReleaseURL(asset string) string

ReleaseURL returns the download URL for a release asset.

func Resolve

func Resolve(ctx context.Context, opts Options) (string, error)

Resolve locates a ready-to-run pg-noop binary: explicit path, embedded copy, local cache, or a verified release download.

Types

type Consent int

Consent controls runtime download of the server binary.

const (
	// ConsentAsk prompts on an interactive terminal and refuses elsewhere.
	ConsentAsk Consent = iota
	// ConsentAlways downloads without prompting (CI, scripts).
	ConsentAlways
	// ConsentNever refuses downloads; only embedded/cached/explicit binaries resolve.
	ConsentNever
)

type Options

type Options struct {
	// Path short-circuits resolution to an explicit binary (flag or env).
	Path string
	// Consent gates the download fallback.
	Consent Consent
	// Prompt receives the interactive download question and the user's answer
	// source. Defaults to stdin/stderr when nil.
	Prompt func(question string) bool
	// Log receives progress lines. Optional.
	Log func(format string, args ...any)
}

Options steers Resolve.

type Server

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

Server is a pg-noop process bound to a loopback port for one baseline run.

func Start

func Start(ctx context.Context, binary string, port int) (*Server, error)

Start launches the server binary on loopback and waits for its listening announcement. Port zero selects an ephemeral port with bounded bind retries.

func (*Server) Addr

func (s *Server) Addr() string

Addr returns the host:port the server listens on.

func (*Server) Port

func (s *Server) Port() int

Port returns the server's listen port.

func (*Server) Stop

func (s *Server) Stop() error

Stop terminates the server: SIGTERM first, SIGKILL after a grace period. The signal-derived exit status is the normal path and not an error.

Jump to

Keyboard shortcuts

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