restarter

package
v3.2.2 Latest Latest
Warning

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

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

Documentation

Overview

Package restarter implements a watchdog for long-running go routines. Whenever the routine stops and return an error, it is restarted periodically.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config interface {
	RestartInterval() time.Duration
	RestartIntervalMaxBackoff() time.Duration
}

type Restartable

type Restartable interface {
	Name() string
	Run(ctx context.Context) (err error, immediateError bool)
}

type Restarter

type Restarter[S Restartable] struct {
	// contains filtered or unexported fields
}

func CreateRestarter

func CreateRestarter[S Restartable](config Config, service S) (w *Restarter[S])

func (*Restarter[S]) GetCtx

func (w *Restarter[S]) GetCtx() context.Context

func (*Restarter[S]) IsRunning

func (w *Restarter[S]) IsRunning() bool

func (*Restarter[S]) Name

func (w *Restarter[S]) Name() string

func (*Restarter[S]) Run

func (w *Restarter[S]) Run()

func (*Restarter[S]) Service

func (w *Restarter[S]) Service() S

func (*Restarter[S]) Shutdown

func (w *Restarter[S]) Shutdown()

Jump to

Keyboard shortcuts

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