當前位置: 首頁>>代碼示例>>Golang>>正文


Golang GetArgs.LeaseClient方法代碼示例

本文整理匯總了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()
	}
}
開發者ID:ammarar,項目名稱:DS-P2,代碼行數:31,代碼來源:libstore-impl.go


注:本文中的P2-f12/official/storageproto.GetArgs.LeaseClient方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。