Documentation
¶
Index ¶
- func MakePGMigrationCMD() cli.Command
- func RegisterNATSFlags(f []cli.Flag) []cli.Flag
- func RegisterPGFlags(f []cli.Flag) []cli.Flag
- func RegisterPprofFlags(f []cli.Flag) []cli.Flag
- func RegisterProbeFlags(f []cli.Flag) []cli.Flag
- func RegisterPromFlags(f []cli.Flag) []cli.Flag
- func RegisterRedisClientFlags(f []cli.Flag) []cli.Flag
- func RegisterS3ClientFlags(f []cli.Flag) []cli.Flag
- func RegisterShutdownFlags(f []cli.Flag) []cli.Flag
- func ShutdownTimeout(c *cli.Context) time.Duration
- type GracefulServer
- type NATS
- type NetnsTCPCollector
- type PG
- type PGMigration
- type Pprof
- type Probe
- type Prom
- type RedisClient
- type S3Client
- type Servable
- type Serve
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MakePGMigrationCMD ¶
func RegisterProbeFlags ¶
RegisterProbeFlags registers cli flags for Probe
func RegisterRedisClientFlags ¶
RegisterRedisClientFlags registers cli flags for RedisClient
func RegisterS3ClientFlags ¶
RegisterS3ClientFlags registers cli flags for S3 client
func RegisterShutdownFlags ¶
RegisterShutdownFlags registers cli flags for GracefulServer
Types ¶
type GracefulServer ¶
type GracefulServer struct {
// contains filtered or unexported fields
}
GracefulServer drains an http.Server on shutdown. Closing only the listener lets the process exit mid-response on SIGTERM, and the ingress answers 502 on every request a terminating pod is still serving.
Close must run before the dependencies the handlers use (Redis, NATS, DB clients) are closed. Defers run in reverse, so either defer Close after all of them or call it explicitly once cs.Serve returns. Close returns only after the handlers are done, including those of streams it cut at the timeout, so their deferred work does not run into closed dependencies. Two exceptions: handlers of hijacked connections (WebSockets), and cut handlers still running 2s after the cut, which Close logs and leaves behind.
The timeout is the one given to NewGracefulServer, usually ShutdownTimeout(c) (WEB_SHUTDOWN_TIMEOUT). It is meant for the service's main web server: the log lines say "web". One GracefulServer serves one http.Server; use NewGracefulServer.
func NewGracefulServer ¶
func NewGracefulServer(timeout time.Duration) *GracefulServer
NewGracefulServer initializes GracefulServer that waits up to timeout for in-flight requests on Close
func (*GracefulServer) Close ¶
func (s *GracefulServer) Close()
Close stops accepting, closes idle keep-alive connections and waits for in-flight requests up to the timeout, then cuts whatever is still open (long-lived streams) with a TCP reset and waits up to 2s for the cut handlers to return. Hijacked connections (WebSockets) are neither waited for nor cut, as with http.Server.Shutdown. It is safe to call more than once and before Serve; every call returns only after the drain is over.
type NetnsTCPCollector ¶
type NetnsTCPCollector struct {
// contains filtered or unexported fields
}
NetnsTCPCollector exports the TCP counters of the network namespace the process runs in, read from /proc/self/net/{netstat,snmp} on every scrape. In a pod that is the pod's own namespace. node-exporter only reads the host's, and the kernel keeps these counters per namespace, so without this the drops and memory-pressure episodes of torrent-http-proxy and the seeders are invisible to Prometheus. On 2026-09-25 they were the cause of playback stalls: 16 MiB receive queues pushed the nodes into TCP memory pressure 59-83% of the time and the proxies dropped 50-180 segments/s.
Processes sharing a namespace (host network, a single-container deployment) report the same numbers.
func NewNetnsTCPCollector ¶
func NewNetnsTCPCollector(dir string) (*NetnsTCPCollector, error)
NewNetnsTCPCollector reads the counters under dir (/proc/self/net in production). It fails when they cannot be read, so a platform without them is reported once at start-up instead of on every scrape.
func (*NetnsTCPCollector) Collect ¶
func (c *NetnsTCPCollector) Collect(ch chan<- prometheus.Metric)
func (*NetnsTCPCollector) Describe ¶
func (c *NetnsTCPCollector) Describe(ch chan<- *prometheus.Desc)
type PGMigration ¶
type PGMigration struct {
// contains filtered or unexported fields
}
func NewPGMigration ¶
func NewPGMigration(db *PG) *PGMigration
func (*PGMigration) Run ¶
func (s *PGMigration) Run(a ...string) error
type Probe ¶
type Probe struct {
// contains filtered or unexported fields
}
Probe provides simple HTTP-service for Kubernetes liveness and readiness checking
type RedisClient ¶
type RedisClient struct {
// contains filtered or unexported fields
}
RedisClient makes Redis Client from cli and environment variables Automatically hanldles Sentinel configuration
func NewRedisClient ¶
func NewRedisClient(c *cli.Context) *RedisClient
NewRedisClient initializes RedisClient
func (*RedisClient) Get ¶
func (s *RedisClient) Get() redis.UniversalClient
Get gets redis.UniversalCleint
type S3Client ¶
type S3Client struct {
// contains filtered or unexported fields
}
S3Client makes AWS SDK S3 Client from cli and environment variables
func NewS3Client ¶
NewS3Client initializes S3Client