Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Drainer ¶
type Drainer struct {
Srv *server.Server
MainServer *http.Server
MgmtServer *http.Server // may be nil
BGCancel context.CancelFunc
BGWait *sync.WaitGroup
TracingShutdown func(context.Context) error // may be nil
// FinishIdleWait, if non-zero, makes Finish wait up to this
// duration for the local server's session count to reach zero
// before tearing down. Set by main.go for the process backend;
// zero for docker (which cuts over hard and relies on the
// reverse proxy to drain the last requests).
FinishIdleWait time.Duration
// ServerID identifies this server process uniquely among peers
// sharing a Redis. Used by waitForIdle to filter the workermap
// so the old server waits for its *own* sessions to finish, not
// the new server's fresh sessions. Set by main.go to the same
// value passed to NewRedisWorkerMap. Safe to leave empty in the
// memory-store path (single-node = all workers are ours).
ServerID string
}
Drainer manages server lifecycle for drain mode (SIGUSR1) and shutdown (SIGTERM). Four methods cover the full rolling update lifecycle:
- Drain / Undrain toggle health endpoint responses (503 / 200).
- Finish tears down the process without evicting workers.
- Shutdown tears down the process and evicts all workers.
func (*Drainer) Drain ¶
func (d *Drainer) Drain()
Drain sets the draining flag. Health endpoints start returning 503, causing the proxy/LB to stop routing new traffic. HTTP listeners stay alive so Undrain() can reverse this without recreating servers.
func (*Drainer) Finish ¶
Finish performs non-destructive teardown: shuts down HTTP servers, cancels background goroutines, closes the database, and flushes tracing. Workers survive — the new server manages them via Redis.
Called after a successful drain in the rolling update path. On the process backend, Finish preludes with an idle-wait that polls the local server's session count until it reaches zero or FinishIdleWait elapses. The prelude is skipped when FinishIdleWait is zero (Docker variant) so Finish's behavior is backwards-compatible with phase 3-4.
In phase 3-4 (without the phase 3-5 watchdog), SIGUSR1 calls Drain() followed by Finish().