hooks

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 13, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

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

func HTTPDrainerShutdown(drainer *shutdown.HTTPDrainer, drainTimeout time.Duration) shutdown.Hook

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

func HTTPServerShutdown(server *http.Server, drainTimeout time.Duration) shutdown.Hook

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

func TelemetryShutdown(metricsFlush func() error, logSync func() error) shutdown.Hook

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

type CacheFlusher interface {
	Flush() error
	Close() error
}

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

type DatabaseContextCloser interface {
	Close(ctx context.Context) error
}

DatabaseContextCloser defines the interface for a database connection that can be closed with context.

type HTTPServer

type HTTPServer interface {
	Shutdown(ctx context.Context) error
	SetKeepAlivesEnabled(v bool)
}

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

type MongoDBClient interface {
	Disconnect(ctx context.Context) error
}

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL