增加带次数的租约续期

This commit is contained in:
2021-11-24 00:06:07 +08:00
parent a9eabd0f19
commit 43cf6f27c9
3 changed files with 132 additions and 4 deletions

View File

@ -46,4 +46,21 @@ type CancelWatcherHandler func(key string, data interface{})
type TimeoutWatcherHandler func(key string, timeout time.Duration)
// LeaseKeepALiveHandler 续期成功的处理
type LeaseKeepALiveHandler func(key string, leaseDetail *clientv3.LeaseKeepAliveResponse)
type LeaseKeepALiveHandler func(data *LeaseKeepAliveData)
// LeaseKeepAliveData 自动续期的数据结构
//
// Author : go_developer@163.com<白茶清欢>
//
// Date : 8:28 下午 2021/11/23
type LeaseKeepAliveData struct {
Key string `json:"key"` // 续期key
StartTime int64 `json:"start_time"` // 开始续期时间
LastLeaseTime int64 `json:"last_lease_time"` // 上一次续期事件时间
LeaseCnt int64 `json:"lease_cnt"` // 续期次数
HasFinish bool `json:"has_finish"` // 是否完成
LeaseFinishType string `json:"lease_finish_type"` // 续期完成类型
LeaseFinishTime int64 `json:"lease_finish_time"` // 续期完成时间
LeaseDetail *clientv3.LeaseKeepAliveResponse `json:"lease_detail"` // 续约数据
Data map[string]interface{} `json:"data"` // 携带的数据
}