本文整理匯總了Golang中github.com/couchbase/sync_gateway/base.SequenceClock.AllAfter方法的典型用法代碼示例。如果您正苦於以下問題:Golang SequenceClock.AllAfter方法的具體用法?Golang SequenceClock.AllAfter怎麽用?Golang SequenceClock.AllAfter使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/couchbase/sync_gateway/base.SequenceClock
的用法示例。
在下文中一共展示了SequenceClock.AllAfter方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: getChanges
// Returns the set of index entries for the channel more recent than the
// specified since SequenceClock. Index entries with sequence values greater than
// the index stable sequence are not returned.
func (k *kvChannelIndex) getChanges(since base.SequenceClock) ([]*LogEntry, error) {
var results []*LogEntry
// Someone is still interested in this channel - reset poll counts
atomic.StoreUint32(&k.pollCount, 0)
atomic.StoreUint32(&k.unreadPollCount, 0)
chanClock, err := k.getChannelClock()
if err != nil {
// Note: gocb returns "Key not found.", go-couchbase returns "MCResponse status=KEY_ENOENT, opcode=GET, opaque=0, msg: Not found"
// Using string matching to identify key not found for now - really need a better API in go-couchbase/gocb for gets that allows us to distinguish
// between errors and key not found with something more robust than string matching.
if IsNotFoundError(err) {
// initialize chanClock as empty clock
chanClock = base.NewSequenceClockImpl()
} else {
return results, err
}
}
// If requested clock is later than the channel clock, return empty
if since.AllAfter(chanClock) {
base.LogTo("DIndex+", "requested clock is later than channel clock - no new changes to report")
return results, nil
}
// If the since value is more recent than the last polled clock, return the results from the
// last polling. Has the potential to return values earlier than since and later than
// lastPolledClock, but these duplicates will be ignored by replication. Could validate
// greater than since inside this if clause, but leaving out as a performance optimization for
// now
if lastPolledResults := k.checkLastPolled(since); len(lastPolledResults) > 0 {
indexExpvars.Add("getChanges_lastPolled_hit", 1)
return lastPolledResults, nil
}
indexExpvars.Add("getChanges_lastPolled_miss", 1)
return k.channelStorage.GetChanges(since, chanClock)
}