heartbeat

package
v1.15.5 Latest Latest
Warning

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

Go to latest
Published: May 10, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Cell = cell.Module(
	"kvstore-heartbeat-updater",
	"KVStore Heartbeat Updater",

	cell.Invoke(func(lc cell.Lifecycle, backendPromise promise.Promise[kvstore.BackendOperations]) {
		ctx, cancel := context.WithCancel(context.Background())
		var wg sync.WaitGroup

		lc.Append(cell.Hook{
			OnStart: func(cell.HookContext) error {
				wg.Add(1)
				go func() {
					defer wg.Done()

					backend, err := backendPromise.Await(ctx)
					if err != nil {

						return
					}

					Heartbeat(ctx, backend)
				}()
				return nil
			},

			OnStop: func(ctx cell.HookContext) error {
				cancel()
				wg.Wait()
				return nil
			},
		})
	}),
)

Cell creates a cell responsible for periodically updating the heartbeat key in the kvstore.

Functions

func Heartbeat

func Heartbeat(ctx context.Context, backend kvstore.BackendOperations)

Heartbeat periodically updates the heatbeat path through the given client, blocking until the context is canceled.

Types

This section is empty.

Jump to

Keyboard shortcuts

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