lifecycle

package
v1.18.0-rc Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2020 License: AGPL-3.0 Imports: 9 Imported by: 3

Documentation

Overview

Package lifecycle allows controlling group of items.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Group

type Group struct {
	// contains filtered or unexported fields
}

Group implements a collection of items that have a concurrent start and are closed in reverse order.

func NewGroup

func NewGroup(log *zap.Logger) *Group

NewGroup creates a new group.

func (*Group) Add

func (group *Group) Add(item Item)

Add adds item to the group.

func (*Group) Close

func (group *Group) Close() error

Close closes all items in reverse order.

func (*Group) Run

func (group *Group) Run(ctx context.Context, g *errgroup.Group)

Run starts all items concurrently under group g.

type Item

type Item struct {
	Name  string
	Run   func(ctx context.Context) error
	Close func() error
}

Item is the lifecycle item that group runs and closes.

Jump to

Keyboard shortcuts

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