Documentation
¶
Index ¶
- func BackgroundWorkerShutdown(name string, worker BackgroundWorker, waitTimeout time.Duration) shutdown.Hook
- func BackgroundWorkerShutdownFunc(worker BackgroundWorker, waitTimeout time.Duration) shutdown.HookFunc
- func CacheFlushAndShutdown(name string, cache CacheFlusher) shutdown.Hook
- func CacheFlushAndShutdownFunc(cache CacheFlusher) shutdown.HookFunc
- func CacheShutdown(name string, cache CacheCloser) shutdown.Hook
- func CacheShutdownFunc(cache CacheCloser) shutdown.HookFunc
- func DatabaseContextShutdown(name string, db DatabaseContextCloser) shutdown.Hook
- func DatabaseContextShutdownFunc(db DatabaseContextCloser) shutdown.HookFunc
- func DatabaseShutdown(name string, db DatabaseCloser) shutdown.Hook
- func DatabaseShutdownFunc(db DatabaseCloser) shutdown.HookFunc
- func HTTPDrainerShutdown(drainer *shutdown.HTTPDrainer, drainTimeout time.Duration) shutdown.Hook
- func HTTPDrainerShutdownFunc(drainer *shutdown.HTTPDrainer, drainTimeout time.Duration) shutdown.HookFunc
- func HTTPServerShutdown(server *http.Server, drainTimeout time.Duration) shutdown.Hook
- func HTTPServerShutdownFunc(server HTTPServer, drainTimeout time.Duration) shutdown.HookFunc
- func JobSchedulerShutdown(name string, scheduler JobScheduler) shutdown.Hook
- func JobSchedulerShutdownFunc(scheduler JobScheduler) shutdown.HookFunc
- func LoggerShutdown(name string, flusher LogFlusher) shutdown.Hook
- func LoggerShutdownFunc(flusher LogFlusher) shutdown.HookFunc
- func MemcachedShutdown(client MemcachedClient) shutdown.Hook
- func MetricsShutdown(name string, flusher MetricsFlusher) shutdown.Hook
- func MetricsShutdownFunc(flusher MetricsFlusher) shutdown.HookFunc
- func MongoDBShutdown(client MongoDBClient) shutdown.Hook
- func RedisShutdown(client RedisClient) shutdown.Hook
- func SQLDBShutdown(db SQLDBCloser) shutdown.Hook
- func TelemetryShutdown(metricsFlush func() error, logSync func() error) shutdown.Hook
- func WorkerPoolShutdown(name string, cancel context.CancelFunc, done <-chan struct{}) shutdown.Hook
- type BackgroundWorker
- type CacheCloser
- type CacheFlusher
- type DatabaseCloser
- type DatabaseContextCloser
- type HTTPServer
- type JobScheduler
- type LogFlusher
- type MemcachedClient
- type MetricsFlusher
- type MongoDBClient
- type RedisClient
- type SQLDBCloser
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BackgroundWorkerShutdown ¶
func BackgroundWorkerShutdown(name string, worker BackgroundWorker, waitTimeout time.Duration) shutdown.Hook
BackgroundWorkerShutdown creates a shutdown hook for a background worker.
func BackgroundWorkerShutdownFunc ¶
func BackgroundWorkerShutdownFunc(worker BackgroundWorker, waitTimeout time.Duration) shutdown.HookFunc
BackgroundWorkerShutdownFunc creates a shutdown hook for a background worker.
func CacheFlushAndShutdown ¶
func CacheFlushAndShutdown(name string, cache CacheFlusher) shutdown.Hook
CacheFlushAndShutdown creates a shutdown hook that flushes then closes a cache.
func CacheFlushAndShutdownFunc ¶
func CacheFlushAndShutdownFunc(cache CacheFlusher) shutdown.HookFunc
CacheFlushAndShutdownFunc creates a shutdown hook that flushes then closes a cache.
func CacheShutdown ¶
func CacheShutdown(name string, cache CacheCloser) shutdown.Hook
CacheShutdown creates a shutdown hook for a cache connection.
func CacheShutdownFunc ¶
func CacheShutdownFunc(cache CacheCloser) shutdown.HookFunc
CacheShutdownFunc creates a shutdown hook for a cache connection.
func DatabaseContextShutdown ¶
func DatabaseContextShutdown(name string, db DatabaseContextCloser) shutdown.Hook
DatabaseContextShutdown creates a shutdown hook for a database with context close.
func DatabaseContextShutdownFunc ¶
func DatabaseContextShutdownFunc(db DatabaseContextCloser) shutdown.HookFunc
DatabaseContextShutdownFunc creates a shutdown hook for a database with context close.
func DatabaseShutdown ¶
func DatabaseShutdown(name string, db DatabaseCloser) shutdown.Hook
DatabaseShutdown creates a shutdown hook for a database connection.
func DatabaseShutdownFunc ¶
func DatabaseShutdownFunc(db DatabaseCloser) shutdown.HookFunc
DatabaseShutdownFunc creates a shutdown hook for a database connection.
func HTTPDrainerShutdown ¶
HTTPDrainerShutdown creates a shutdown hook for an HTTPDrainer.
func HTTPDrainerShutdownFunc ¶
func HTTPDrainerShutdownFunc(drainer *shutdown.HTTPDrainer, drainTimeout time.Duration) shutdown.HookFunc
HTTPDrainerShutdownFunc creates a shutdown hook that drains HTTP connections.
func HTTPServerShutdown ¶
HTTPServerShutdown creates a shutdown hook for the standard http.Server.
func HTTPServerShutdownFunc ¶
func HTTPServerShutdownFunc(server HTTPServer, drainTimeout time.Duration) shutdown.HookFunc
HTTPServerShutdownFunc creates a shutdown hook for an HTTP server. It disables keep-alives and waits for active connections to drain.
func JobSchedulerShutdown ¶
func JobSchedulerShutdown(name string, scheduler JobScheduler) shutdown.Hook
JobSchedulerShutdown creates a shutdown hook for a job scheduler.
func JobSchedulerShutdownFunc ¶
func JobSchedulerShutdownFunc(scheduler JobScheduler) shutdown.HookFunc
JobSchedulerShutdownFunc creates a shutdown hook for a job scheduler.
func LoggerShutdown ¶
func LoggerShutdown(name string, flusher LogFlusher) shutdown.Hook
LoggerShutdown creates a shutdown hook for logger syncing.
func LoggerShutdownFunc ¶
func LoggerShutdownFunc(flusher LogFlusher) shutdown.HookFunc
LoggerShutdownFunc creates a shutdown hook for logger syncing.
func MemcachedShutdown ¶
func MemcachedShutdown(client MemcachedClient) shutdown.Hook
MemcachedShutdown creates a shutdown hook for a Memcached client.
func MetricsShutdown ¶
func MetricsShutdown(name string, flusher MetricsFlusher) shutdown.Hook
MetricsShutdown creates a shutdown hook for metrics flushing.
func MetricsShutdownFunc ¶
func MetricsShutdownFunc(flusher MetricsFlusher) shutdown.HookFunc
MetricsShutdownFunc creates a shutdown hook for metrics flushing.
func MongoDBShutdown ¶
func MongoDBShutdown(client MongoDBClient) shutdown.Hook
MongoDBShutdown creates a shutdown hook for a MongoDB client.
func RedisShutdown ¶
func RedisShutdown(client RedisClient) shutdown.Hook
RedisShutdown creates a shutdown hook for a Redis client.
func SQLDBShutdown ¶
func SQLDBShutdown(db SQLDBCloser) shutdown.Hook
SQLDBShutdown creates a shutdown hook for a SQL database.
func TelemetryShutdown ¶
TelemetryShutdown creates a shutdown hook for combined metrics and logging.
func WorkerPoolShutdown ¶
func WorkerPoolShutdown(name string, cancel context.CancelFunc, done <-chan struct{}) shutdown.Hook
WorkerPoolShutdown creates a shutdown hook that cancels a context and waits for a done channel.
Types ¶
type BackgroundWorker ¶
type BackgroundWorker interface {
// Shutdown signals the worker to stop accepting new jobs.
Shutdown()
// WaitForCompletion waits for all current jobs to complete or timeout.
WaitForCompletion(timeout time.Duration)
}
BackgroundWorker defines the interface for a background worker that can be shut down.
type CacheCloser ¶
type CacheCloser interface {
Close() error
}
CacheCloser defines the interface for a cache connection that can be closed.
type CacheFlusher ¶
CacheFlusher defines the interface for a cache that can flush data before closing.
type DatabaseCloser ¶
type DatabaseCloser interface {
Close() error
}
DatabaseCloser defines the interface for a database connection that can be closed.
type DatabaseContextCloser ¶
DatabaseContextCloser defines the interface for a database connection that can be closed with context.
type HTTPServer ¶
HTTPServer defines the interface for an HTTP server that can be shut down.
type JobScheduler ¶
type JobScheduler interface {
// Shutdown stops the scheduler from starting new jobs.
Shutdown()
// WaitForJobs waits for all running jobs to complete.
WaitForJobs(ctx context.Context) error
}
JobScheduler defines the interface for a job scheduler that can be shut down.
type LogFlusher ¶
type LogFlusher interface {
Sync() error
}
LogFlusher defines the interface for a logger that can be flushed.
type MemcachedClient ¶
type MemcachedClient interface {
Close()
}
MemcachedClient defines the interface for a Memcached client that can be closed.
type MetricsFlusher ¶
type MetricsFlusher interface {
Flush() error
}
MetricsFlusher defines the interface for metrics that can be flushed.
type MongoDBClient ¶
MongoDBShutdown creates a shutdown hook for a MongoDB client. MongoDB client uses Disconnect(ctx) instead of Close().
type RedisClient ¶
type RedisClient interface {
Close() error
}
RedisClient defines the interface for a Redis client that can be closed.
type SQLDBCloser ¶
type SQLDBCloser interface {
Close() error
}
SQLDBShutdown creates a shutdown hook for a *sql.DB compatible database.