Expand description
The balancerd service is a horizontally scalable, stateless, multi-tenant ingress router for pgwire and HTTPS connections.
It listens on pgwire and HTTPS ports. When a new pgwire connection starts, the requested user is authenticated with frontegg from which a tenant id is returned. From that a target internal hostname is resolved to an IP address, and the connection is proxied to that address which has a running environmentdβs pgwire port. When a new HTTPS connection starts, its SNI hostname is used to generate an internal hostname that is resolved to an IP address, which is similarly proxied.
ModulesΒ§
StructsΒ§
- Balancer
Config - Balancer
Metrics - Prometheus monitoring metrics.
- Balancer
Service - Counting
Conn π - Frontegg
Resolver - Gauge
Guard π - Wraps an IntGauge and automatically
inc
s on init anddrop
s on drop. Callers should not callinc().
. Useful for handling multiple task exit points, for example in the case of a panic. - Https
Balancer π - Internal
Http πServer - Pgwire
Balancer π - Resolved
Addr π - Server
Metrics π - Server
Metrics πConfig
EnumsΒ§
ConstantsΒ§
- BUILD_
INFO - Balancer build information.
TraitsΒ§
- Client
Stream π
FunctionsΒ§
- cancel_
request π - Broadcasts cancellation to all matching environmentds.
conn_id
βs bits [31..20] are the lower 12 bits of a UUID for an environmentd/organization. Using that and the template incancellation_resolver
we generate a hostname. That hostname resolves to all IPs of envds that match the UUID (cloud k8s infrastructure maintains that mapping). This function creates a new task for each envd and relays the cancellation message to it, broadcasting it to any envd that might match the connection. - handle_
readiness_ πcheck - lookup π
- Returns the first IP address resolved from the provided hostname.