MCPcopy Create free account
hub / github.com/couchbase/sync_gateway / getHistoryWithTimeout

Function getHistoryWithTimeout

db/revtree_test.go:1142–1165  ·  view source on GitHub ↗
(rawDoc *Document, revId string, timeout time.Duration)

Source from the content-addressed store, hash-verified

1140}
1141
1142func getHistoryWithTimeout(rawDoc *Document, revId string, timeout time.Duration) (history []string, err error) {
1143
1144 historyChannel := make(chan []string)
1145 errChannel := make(chan error)
1146
1147 go func() {
1148 history, err := rawDoc.History.getHistory(revId)
1149 if err != nil {
1150 errChannel <- err
1151 } else {
1152 historyChannel <- history
1153 }
1154 }()
1155
1156 select {
1157 case history := <-historyChannel:
1158 return history, nil
1159 case err := <-errChannel:
1160 return nil, err
1161 case _ = <-time.After(timeout):
1162 return nil, fmt.Errorf("Timeout waiting for history")
1163 }
1164
1165}
1166
1167// ////// BENCHMARK:
1168

Callers 1

Calls 3

getHistoryMethod · 0.80
AfterMethod · 0.80
ErrorfMethod · 0.80

Tested by

no test coverage detected