heartbeat

package
v1.14.0-snapshot.6 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2023 License: Apache-2.0 Imports: 11 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 hive.Lifecycle, backendPromise promise.Promise[kvstore.BackendOperations]) {
		ctx, cancel := context.WithCancel(context.Background())
		var wg sync.WaitGroup

		lc.Append(hive.Hook{
			OnStart: func(hive.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 hive.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