endpoints

package
v0.7.0 Latest Latest
Warning

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

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

Documentation

Overview

Package endpoints reads one Service's endpoints on request (design §9.3). The interface is platform neutral (D-016); a provider implements it.

Index

Constants

View Source
const (
	Complete    = "complete"
	Partial     = "partial"
	Failed      = "failed"
	Unavailable = "unavailable"
	TimedOut    = "timed-out"
	Busy        = "busy"
)

The completeness of a Result.

Variables

View Source
var DefaultBounds = Bounds{InFlight: 4, MemoServices: 32, MemoBytes: 1 << 20, MaxEndpoints: 1000, PageSize: 10, MaxPages: 10,
	Timeout: 2 * time.Second, TTL: 5 * time.Second}

DefaultBounds are the design's bounds.

Functions

This section is empty.

Types

type Bounds

type Bounds struct {
	InFlight, MemoServices, MemoBytes, MaxEndpoints, PageSize, MaxPages int
	Timeout, TTL                                                        time.Duration
}

Bounds limit the reads behind a ScopedReader process-wide (design §9.3). InFlight is the most reads at once; MemoServices, MemoBytes and TTL bound the memo. MaxEndpoints, PageSize and MaxPages bound one read; Bounded also cuts a longer result to MaxEndpoints.

type Endpoint

type Endpoint struct {
	Address                     string
	Port                        int32
	PortName                    string
	Ready, Serving, Terminating bool
	Pod                         string
}

Endpoint is one address and port of a Service. Pod is the target Pod's name when the provider names one.

type Result

type Result struct {
	Items    []Endpoint
	Complete string
	ReadAt   time.Time
}

Result is one read of a Service's endpoints. Only a Complete result establishes that Items is every endpoint. Callers must not modify Items.

type ScopedReader

type ScopedReader interface {
	Endpoints(ctx context.Context, installID string, svc objects.Ref) (Result, error)
}

ScopedReader reads the endpoints of Service svc in the install with ID installID. It takes the ID, not an install, so providers need not import pkg/install. Callers authorise the backend before every call, memo hits included.

var NoReader ScopedReader = noReader{}

NoReader is the reader of a provider without one: every result is Unavailable.

func Bounded

func Bounded(r ScopedReader, b Bounds, clk clock.Clock) ScopedReader

Bounded wraps r: duplicate requests share one read, at most b.InFlight reads run (a further one is Busy), a read is TimedOut after b.Timeout, and complete and partial results are remembered for b.TTL, least recently used first, within b.MemoServices and b.MemoBytes. Only Service refs are read; others are Unavailable.

Jump to

Keyboard shortcuts

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