storewatch

package
v1.1.0-beta.0...-e641d2c Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2024 License: Apache-2.0, Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

package storewatch provides a `Watcher` type which allows the user to listen the events of lifetime of stores.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Callback

type Callback interface {
	OnNewStoreRegistered(store *metapb.Store)
	OnDisconnect(store *metapb.Store)
	OnReboot(store *metapb.Store)
}

Callback will be called the supported event triggered.

func MakeCallback

func MakeCallback(opts ...DynCallbackOpt) Callback

MakeCallback creates a callback with the given options. Allowed options: WithOnNewStoreRegistered, WithOnDisconnect, WithOnReboot.

type DynCallback

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

DynCallback is a function based callback set.

func (*DynCallback) OnDisconnect

func (cb *DynCallback) OnDisconnect(store *metapb.Store)

OnDisconnect will be called once the store is disconnected.

func (*DynCallback) OnNewStoreRegistered

func (cb *DynCallback) OnNewStoreRegistered(store *metapb.Store)

OnNewStoreRegistered will be called once new region added to be watched.

func (*DynCallback) OnReboot

func (cb *DynCallback) OnReboot(store *metapb.Store)

OnReboot will be called once the store is rebooted.

type DynCallbackOpt

type DynCallbackOpt func(*DynCallback)

DynCallbackOpt is the option for DynCallback.

func WithOnDisconnect

func WithOnDisconnect(f func(*metapb.Store)) DynCallbackOpt

WithOnDisconnect adds a hook to the callback.

func WithOnNewStoreRegistered

func WithOnNewStoreRegistered(f func(*metapb.Store)) DynCallbackOpt

WithOnNewStoreRegistered adds a hook to the callback.

func WithOnReboot

func WithOnReboot(f func(*metapb.Store)) DynCallbackOpt

WithOnReboot adds a hook to the callback.

type Watcher

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

Watcher watches the lifetime of stores. generally it should be advanced by calling the `Step` call.

func New

func New(cli util.StoreMeta, cb Callback) *Watcher

func (*Watcher) Step

func (w *Watcher) Step(ctx context.Context) error

Jump to

Keyboard shortcuts

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