Documentation
¶
Overview ¶
Package lb emulates the Application Load Balancer (SRS 5.8): the compute v1 load-balancing collections (forwarding rules, target HTTP(S) proxies, URL maps, backend services and buckets, health checks, SSL certificates and SSL policies, global and regional; FR-LB-001) served on the compute API, and a real in-process L7 proxy per forwarding rule wired exactly as GCP wires them: forwarding rule → target proxy → URL map → backend service or bucket → NEG endpoints (FR-LB-002..010). Cloud Armor security policies, target TCP, SSL and gRPC proxies and legacy HTTP(S) health checks are recorded: served by the API with no data-plane effect.
The routing engine (FR-LB-003) is the pure package lb/urlmap. Cloud CDN (services/cdn) wraps backends with enableCdn; Certificate Manager and Network Security resources come from the "certs" service (emu.CertManager).
Index ¶
- Variables
- func New(env *emu.Env) emu.Service
- type LogEntry
- type Options
- type Service
- func (s *Service) ApplySeed(ctx context.Context, section *yaml.Node, baseDir string) error
- func (s *Service) CertificateMapTargets(ctx context.Context, certificateMap string) []certs.GclbTarget
- func (s *Service) CertsResourceUsers(ctx context.Context, name string) []string
- func (s *Service) DialBackend(ctx context.Context, addr string) (net.Conn, error)
- func (s *Service) EnvVars(gateway string, endpoints map[string]string) map[string]string
- func (s *Service) ForwardingRuleIPs(ctx context.Context, project string) []string
- func (s *Service) Name() string
- func (s *Service) PushTransport() http.RoundTripper
- func (s *Service) Ready() error
- func (s *Service) Register(r emu.Router) error
- func (s *Service) Reset(ctx context.Context) error
- func (s *Service) ResourceCounts() map[string]int
- func (s *Service) SetOptions(o Options)
- func (s *Service) SignedURLKeys(backend string) map[string][]byte
- func (s *Service) Start(ctx context.Context) error
- func (s *Service) Stop(ctx context.Context) error
Constants ¶
This section is empty.
Variables ¶
var Images = map[string]string{
"lb-edge": edgeImage,
}
Images lists the container images the lb service launches (pinned by tag; digests are pinned at release).
Functions ¶
Types ¶
type LogEntry ¶
type LogEntry struct {
InsertID string `json:"insertId"`
LogName string `json:"logName"`
Resource logResource `json:"resource"`
Timestamp string `json:"timestamp"`
Severity string `json:"severity"`
HTTPRequest httpRequest `json:"httpRequest"`
JSONPayload map[string]any `json:"jsonPayload"`
Trace string `json:"trace,omitempty"`
Labels map[string]string `json:"labels,omitempty"`
}
LogEntry is the Cloud Logging entry of one load-balanced request.
type Options ¶
type Options struct {
// DirectDial makes the proxy dial NEG endpoints directly from the host
// instead of through the relay container (host-reachable test backends).
DirectDial bool
// Edge forces the lb-edge container for forwarding rules on privileged
// ports even when binding fails for another reason.
Edge bool
}
Options tune the data plane (tests).
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service is the lb service module.
func (*Service) CertificateMapTargets ¶
func (s *Service) CertificateMapTargets(ctx context.Context, certificateMap string) []certs.GclbTarget
CertificateMapTargets lists the target HTTPS proxies using a certificate map with their forwarding rule addresses (Certificate Manager gclbTargets).
func (*Service) CertsResourceUsers ¶
CertsResourceUsers returns load balancer resources referencing a Certificate Manager or Network Security resource (certificate maps, server TLS policies, backend authentication configs).
func (*Service) DialBackend ¶
DialBackend connects to a backend endpoint exactly as the proxy does (through the lb-edge relay for GKE pod IPs). Diagnostics and tests use it to reach endpoints the host cannot route to.
func (*Service) EnvVars ¶
EnvVars implements emu.EnvVarer: one GCPEMU_LB_<NAME>=host:port per forwarding rule listener (FR-LB-002).
func (*Service) ForwardingRuleIPs ¶
ForwardingRuleIPs returns the forwarding rule IPs of a project and their mapped listener IPs (Certificate Manager load balancer authorization).
func (*Service) PushTransport ¶
func (s *Service) PushTransport() http.RoundTripper
PushTransport returns an HTTP transport for in-process clients (Pub/Sub push, FR-INT-011) that resolves host names through the emulated Cloud DNS, delivers requests addressed to a forwarding rule (or its mapped listener) straight to the load balancer's listener, and trusts the emulator CA in addition to the system roots, so a push endpoint such as https://app.example.test/push reaches the service behind the load balancer.
func (*Service) Register ¶
Register installs the load-balancing collections on the compute API's mux (so selfLinks, operations, filters and paging are uniform with the rest of compute) and the resource-in-use checks (FR-CORE-026).
func (*Service) ResourceCounts ¶ added in v0.2.0
ResourceCounts implements emu.ResourceCounter.
func (*Service) SetOptions ¶
SetOptions changes data-plane options (call before creating resources).
func (*Service) SignedURLKeys ¶
SignedURLKeys returns the signed URL/cookie keys (name → raw 128-bit key) of a backend service or bucket given by selfLink or path, for Cloud CDN signed request validation (FR-CDN-007).
Source Files
¶
- accesslog.go
- backend.go
- backends.go
- bucket.go
- dataplane.go
- dnsmap.go
- echoagent.go
- edge.go
- edgeagent.go
- frontend.go
- frules.go
- headers.go
- health.go
- healthchecks.go
- kinds.go
- l4proxies.go
- lb.go
- lenient.go
- listeners.go
- managedcerts.go
- proxies.go
- proxyproto.go
- pushtransport.go
- refs.go
- resource.go
- securitypolicies.go
- seed.go
- sslcerts.go
- sslpolicies.go
- urlmaps.go
Directories
¶
| Path | Synopsis |
|---|---|
|
Package urlmap is the load balancer's URL map routing engine (FR-LB-003): a pure library that compiles a compute v1 UrlMap and selects, for a request, the backend (service or bucket), redirect, URL rewrite and header actions exactly as GCP's Application Load Balancers do:
|
Package urlmap is the load balancer's URL map routing engine (FR-LB-003): a pure library that compiles a compute v1 UrlMap and selects, for a request, the backend (service or bucket), redirect, URL rewrite and header actions exactly as GCP's Application Load Balancers do: |