本文整理匯總了Golang中P2-f12/official/storageproto.GetArgs.LeaseClient方法的典型用法代碼示例。如果您正苦於以下問題:Golang GetArgs.LeaseClient方法的具體用法?Golang GetArgs.LeaseClient怎麽用?Golang GetArgs.LeaseClient使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類P2-f12/official/storageproto.GetArgs
的用法示例。
在下文中一共展示了GetArgs.LeaseClient方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: checkWhetherLeaseNeeded
func (ls *Libstore) checkWhetherLeaseNeeded(args *storageproto.GetArgs, key string) {
if ls.flags == ALWAYS_LEASE {
args.WantLease = true
args.LeaseClient = ls.cacheCallbackHostPort
} else if ls.cacheCallbackHostPort == "" {
args.WantLease = false
} else {
ls.requestsLocker.Lock()
if ls.requests[key] == nil {
lsplog.Vlogf(3, "[checkWhetherLeaseNeeded] First requested")
req := &Request{1, time.Now().Add(time.Duration(storageproto.QUERY_CACHE_SECONDS) * time.Second)}
ls.requests[key] = req
} else {
req := ls.requests[key]
if time.Now().Before(req.ts) {
req.frequency = req.frequency + 1
if req.frequency >= storageproto.QUERY_CACHE_THRESH {
lsplog.Vlogf(3, "[checkWhetherLeaseNeeded] Going to ask for a lease")
args.LeaseClient = ls.cacheCallbackHostPort
args.WantLease = true
} else {
args.WantLease = false
}
} else {
delete(ls.requests, key)
args.WantLease = false
}
}
ls.requestsLocker.Unlock()
}
}