本文整理汇总了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)
}