Documentation ¶
Index ¶
- Constants
- Variables
- func MatchEvent(event, flag uint32) bool
- type Client
- func (c *Client) AllocID(ctx context.Context, req *pdpb.AllocIDReq) (*pdpb.AllocIDRsp, error)
- func (c *Client) AskSplit(ctx context.Context, req *pdpb.AskSplitReq) (*pdpb.AskSplitRsp, error)
- func (c *Client) BootstrapCluster(ctx context.Context, req *pdpb.BootstrapClusterReq) (*pdpb.BootstrapClusterRsp, error)
- func (c *Client) CellHeartbeat(ctx context.Context, req *pdpb.CellHeartbeatReq) (*pdpb.CellHeartbeatRsp, error)
- func (c *Client) Close() error
- func (c *Client) GetClusterID(ctx context.Context, req *pdpb.GetClusterIDReq) (*pdpb.GetClusterIDRsp, error)
- func (c *Client) GetInitParams(ctx context.Context, req *pdpb.GetInitParamsReq) (*pdpb.GetInitParamsRsp, error)
- func (c *Client) GetLastPD() string
- func (c *Client) GetLastRanges(ctx context.Context, req *pdpb.GetLastRangesReq) (*pdpb.GetLastRangesRsp, error)
- func (c *Client) GetLeader(ctx context.Context, req *pdpb.LeaderReq) (*pdpb.LeaderRsp, error)
- func (c *Client) GetStore(ctx context.Context, req *pdpb.GetStoreReq) (*pdpb.GetStoreRsp, error)
- func (c *Client) IsClusterBootstrapped(ctx context.Context, req *pdpb.IsClusterBootstrapReq) (*pdpb.IsClusterBootstrapRsp, error)
- func (c *Client) ListStore(ctx context.Context, req *pdpb.ListStoreReq) (*pdpb.ListStoreRsp, error)
- func (c *Client) PutStore(ctx context.Context, req *pdpb.PutStoreReq) (*pdpb.PutStoreRsp, error)
- func (c *Client) RegisterWatcher(ctx context.Context, req *pdpb.RegisterWatcherReq) (*pdpb.RegisterWatcherRsp, error)
- func (c *Client) ReportSplit(ctx context.Context, req *pdpb.ReportSplitReq) (*pdpb.ReportSplitRsp, error)
- func (c *Client) SetName(name string)
- func (c *Client) StoreHeartbeat(ctx context.Context, req *pdpb.StoreHeartbeatReq) (*pdpb.StoreHeartbeatRsp, error)
- func (c *Client) WatcherHeartbeat(ctx context.Context, req *pdpb.WatcherHeartbeatReq) (*pdpb.WatcherHeartbeatRsp, error)
- type Watcher
Constants ¶
const ( // ZeroID use for check ZeroID uint64 = 0 )
Variables ¶
var ( // EventInit event init EventInit = uint32(1 << 1) // EventCellCreated event cell created EventCellCreated = uint32(1 << 2) // EventCellLeaderChanged event cell created EventCellLeaderChanged = uint32(1 << 3) // EventCellRangeChaned event cell range changed EventCellRangeChaned = uint32(1 << 4) // EventCellPeersChaned event cell peer changed EventCellPeersChaned = uint32(1 << 5) // EventStoreUp event store status was up EventStoreUp = uint32(1 << 6) // EventStoreDown event store status was down EventStoreDown = uint32(1 << 7) // EventStoreTombstone event store status was tombstone EventStoreTombstone = uint32(1 << 8) // EventFlagCell all cell event EventFlagCell = uint32(EventCellCreated | EventCellLeaderChanged | EventCellRangeChaned | EventCellPeersChaned) // EventFlagStore all store event EventFlagStore = uint32(EventStoreUp | EventStoreDown | EventStoreTombstone) // EventFlagAll all event EventFlagAll = uint32(0xffffffff) )
var ( // ErrNotLeader pd is not leader ErrNotLeader = errors.New("PD Server Not Leader") )
var ( // ErrWatcherStopped watcher is stopped ErrWatcherStopped = errors.New("watcher is stopped") )
Functions ¶
func MatchEvent ¶
MatchEvent returns the flag has the target event
Types ¶
type Client ¶
Client pd client
func (*Client) AllocID ¶
func (c *Client) AllocID(ctx context.Context, req *pdpb.AllocIDReq) (*pdpb.AllocIDRsp, error)
AllocID returns a uniq id
func (*Client) AskSplit ¶
func (c *Client) AskSplit(ctx context.Context, req *pdpb.AskSplitReq) (*pdpb.AskSplitRsp, error)
AskSplit returns ask split response
func (*Client) BootstrapCluster ¶
func (c *Client) BootstrapCluster(ctx context.Context, req *pdpb.BootstrapClusterReq) (*pdpb.BootstrapClusterRsp, error)
BootstrapCluster returns bootstrap cluster response
func (*Client) CellHeartbeat ¶
func (c *Client) CellHeartbeat(ctx context.Context, req *pdpb.CellHeartbeatReq) (*pdpb.CellHeartbeatRsp, error)
CellHeartbeat returns cell heartbeat response
func (*Client) GetClusterID ¶
func (c *Client) GetClusterID(ctx context.Context, req *pdpb.GetClusterIDReq) (*pdpb.GetClusterIDRsp, error)
GetClusterID returns cluster id
func (*Client) GetInitParams ¶
func (c *Client) GetInitParams(ctx context.Context, req *pdpb.GetInitParamsReq) (*pdpb.GetInitParamsRsp, error)
GetInitParams returns cluster init params
func (*Client) GetLastRanges ¶
func (c *Client) GetLastRanges(ctx context.Context, req *pdpb.GetLastRangesReq) (*pdpb.GetLastRangesRsp, error)
GetLastRanges returns lastest key ranges
func (*Client) GetStore ¶
func (c *Client) GetStore(ctx context.Context, req *pdpb.GetStoreReq) (*pdpb.GetStoreRsp, error)
GetStore returns get store response
func (*Client) IsClusterBootstrapped ¶
func (c *Client) IsClusterBootstrapped(ctx context.Context, req *pdpb.IsClusterBootstrapReq) (*pdpb.IsClusterBootstrapRsp, error)
IsClusterBootstrapped returns cluster is bootstrapped response
func (*Client) ListStore ¶
func (c *Client) ListStore(ctx context.Context, req *pdpb.ListStoreReq) (*pdpb.ListStoreRsp, error)
ListStore returns list store response
func (*Client) PutStore ¶
func (c *Client) PutStore(ctx context.Context, req *pdpb.PutStoreReq) (*pdpb.PutStoreRsp, error)
PutStore returns put store response
func (*Client) RegisterWatcher ¶
func (c *Client) RegisterWatcher(ctx context.Context, req *pdpb.RegisterWatcherReq) (*pdpb.RegisterWatcherRsp, error)
RegisterWatcher register a watcher for newest cell info notify
func (*Client) ReportSplit ¶
func (c *Client) ReportSplit(ctx context.Context, req *pdpb.ReportSplitReq) (*pdpb.ReportSplitRsp, error)
ReportSplit returns report split response
func (*Client) StoreHeartbeat ¶
func (c *Client) StoreHeartbeat(ctx context.Context, req *pdpb.StoreHeartbeatReq) (*pdpb.StoreHeartbeatRsp, error)
StoreHeartbeat returns store heartbeat response
func (*Client) WatcherHeartbeat ¶
func (c *Client) WatcherHeartbeat(ctx context.Context, req *pdpb.WatcherHeartbeatReq) (*pdpb.WatcherHeartbeatRsp, error)
WatcherHeartbeat update the watcher lastest alive time
type Watcher ¶
Watcher is watch pd event
func NewWatcher ¶
NewWatcher returns a watcher. The watcher will listen form pd at the addr parameter
func (*Watcher) Ready ¶
func (w *Watcher) Ready() (*pdpb.WatchEvent, error)
Ready returns the event return a error if watcher was stopped