lifetime

package
v0.0.0-...-1593278 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2023 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Overview

package lifetime provides common component lifetime control logic.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type IsHealthy

type IsHealthy[T any] func(T) bool

IsHealthy function type for lifetime healthy check.

type Lifetime

type Lifetime[T any] interface {
	// SetState is the method to change lifetime state.
	SetState(state T)
	// GetState returns current state.
	GetState() T
	// Add records a task is running, returns false if the lifetime is not healthy.
	Add(isHealthy IsHealthy[T]) bool
	// Done records a task is done.
	Done()
	// Wait waits until all tasks are done.
	Wait()
}

Lifetime interface for lifetime control.

func NewLifetime

func NewLifetime[T any](initState T) Lifetime[T]

NewLifetime returns a new instance of Lifetime with init state and isHealthy logic.

Jump to

Keyboard shortcuts

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