published

package
v0.10.0-rc.2 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2026 License: Apache-2.0 Imports: 8 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package published chooses the Published ports (ADR 0012) a Containerized Instance serves host clients on: the ports its own container publishes to the host. GKE LoadBalancer Services (on a VM runtime) and forwarding rules (on any runtime) share them, and whoever binds a port first wins.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ListenShared

func ListenShared(addr string) (net.Listener, error)

ListenShared listens on addr like net.Listen, but lets a listener on the wildcard address and one on a specific address share a port (Linux refuses that otherwise), when both are opened with it. A forwarding rule's loopback listener and a Published port listener on the rule's own port need that in a Containerized Instance. Sharing also lets two wildcard listeners share a port, so callers must keep track of the ports they hold themselves; a plain listener (another process, or a GKE LoadBalancer Service) still refuses it.

Types

type Binding added in v0.8.0

type Binding struct {
	Listener net.Listener
	// Port is the container port, and Host its host address.
	Port int
	Host string
}

Binding is a listener on a Published port.

type OwnPortPolicy added in v0.8.0

type OwnPortPolicy int

OwnPortPolicy says when an Own port comes first among its candidates.

const (
	// SameHostPort: when the container publishes it at the same host
	// port (GKE LoadBalancer Services).
	SameHostPort OwnPortPolicy = iota
	// AnyHostPort: when the container publishes it at any host port
	// (forwarding rules).
	AnyHostPort
)

type Ports added in v0.8.0

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

Ports is what a Containerized Instance knows of its container's Published ports: the ports it publishes, and --port-range.

func NewPorts added in v0.8.0

func NewPorts(published map[int]string, c *config.Config) *Ports

NewPorts returns the Ports of a container that publishes published (runtime.Client.SelfPorts) under the Instance's config c.

func (*Ports) Bind added in v0.8.0

func (p *Ports) Bind(cands []int, listen func(port int) (net.Listener, error), skip func(port int) bool) *Binding

Bind listens on the first of cands that skip (when set) does not report and listen binds, and returns that binding; nil when none binds.

func (*Ports) Candidates added in v0.8.0

func (p *Ports) Candidates(name string, own int, policy OwnPortPolicy) []int

Candidates lists the container ports to try serving port own on, in order: own itself when the container publishes it as policy says, then the published ports of --port-range, from a hash of name onwards, so that name keeps its port across syncs and restarts where it can.

func (*Ports) Hint added in v0.8.0

func (p *Ports) Hint(own int, what string) string

Hint says what to publish so that port own of what ("the Service", "the forwarding rule") can be served.

func (*Ports) Len added in v0.8.0

func (p *Ports) Len() int

Len is the number of ports the container publishes; 0 for nil.

Jump to

Keyboard shortcuts

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