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

address

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2026 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Overview

Package address changes where a configured app is reached (R-162, R-163, R-165).

An app's address is its spec's routing block, and changing it is a spec revision like any other edit (R-152). What this package adds is the part that is not a plain field edit: which modes the chosen routing adapter serves, what the hostname, path or port defaults to under it, and whether the result deviates from the adapter's default mode — which R-163 gates behind app.routing.override. The HTTP handler asks the authorizer; the decision of what needs asking is made here, once, for every surface.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Decision

type Decision struct {
	Routing spec.Routing

	// Changed is whether it differs from the current routing. A change moves
	// the app: the old address stops working, and bookmarks to it break
	// (R-165), which is why the caller asks for confirmation.
	Changed bool

	// Override is whether the mode deviates from the adapter's default, which
	// needs app.routing.override (R-163). Keeping a deviation an app already
	// has is not a new one and is not asked about again.
	Override bool
}

Decision is a resolved routing change.

type Option

type Option struct {
	AdapterRef  string             `json:"adapter_ref"`
	Modes       []spec.RoutingMode `json:"modes"`
	DefaultMode spec.RoutingMode   `json:"default_mode"`
	BaseDomain  string             `json:"base_domain,omitempty"`
	IsDefault   bool               `json:"is_default"`
}

Option is a routing adapter an app can be moved to, and what it offers.

type Ports

type Ports interface {
	Allocate(ctx context.Context, adapterRef, appID string, from, to int) (int, error)
}

Ports allocates a host port for port-mode routing (design 03 §4.2). Idempotent: an app that holds a port on an adapter gets the same one back.

type Request

type Request struct {
	AdapterRef string           `json:"adapter_ref,omitempty"`
	Mode       spec.RoutingMode `json:"mode,omitempty"`
	Hostname   string           `json:"hostname,omitempty"`
	PathPrefix string           `json:"path_prefix,omitempty"`
}

Request is the address somebody asked for. Empty fields take the adapter's default: its default mode, and the hostname, path or port that mode implies. A port is always allocated, never named.

type Service

type Service struct {
	Registry *api.Registry
	Ports    Ports
	Taken    Taken

	// PortRangeStart and PortRangeEnd are the install's port range.
	PortRangeStart, PortRangeEnd int

	// BaseDomain is the install's server.base_domain, used when the routing
	// adapter has no domain of its own.
	BaseDomain string
}

Service resolves routing changes against the configured routing adapters.

func (*Service) Options

func (s *Service) Options(ctx context.Context) []Option

Options lists the routing adapters an app's address can use. One that cannot say what it serves is left out rather than offered and refused.

func (*Service) Overrides

func (s *Service) Overrides(ctx context.Context, current *spec.Routing, next *spec.Routing) (bool, error)

Overrides reports whether next deviates from its adapter's default mode where current did not — for a spec written whole, through POST /specs, rather than through Resolve. It also corrects next's ModeSource, which a hand-written spec may have left saying anything.

func (*Service) Resolve

func (s *Service) Resolve(ctx context.Context, appID, slug string, current spec.Routing, req Request) (Decision, error)

Resolve works out the routing an app would have under req.

type Taken

type Taken interface {
	CheckAddress(ctx context.Context, appID string, r spec.Routing) error
}

Taken reports whether another app already holds an address.

Jump to

Keyboard shortcuts

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