heartbeat

package
v0.0.0-...-5fb48e9 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package heartbeat provides a mechanism for heartbeating against Redis to ensure it's still healthy.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	RedisClient redisClient
	Logger      zerolog.Logger
	AppName     string
	UID         string
	Warn        time.Duration
	Fail        time.Duration
	ShutdownFn  func(zerolog.Logger)
}

type Heart

type Heart struct {

	// Done is closed when the Heart has stopped (due to Redis failure)
	Done <-chan struct{}
	// contains filtered or unexported fields
}

Heart is the thing that beats.

func New

func New(ctx context.Context, cfg Config) (*Heart, error)

New is a function with an argument list that's roughly the size of Texas. The appName and UID are used as part of the key written to Redis. The warn and fail durations control when we log a warning, and when we start to exit (respectively). Finally, there's a shutdownFn if you want to clean up some things before the program exits. That function has 10 seconds to complete, otherwise the program is forcibly exited.

If the error is not nil, the *Heart is beating.

Jump to

Keyboard shortcuts

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