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.