(rawDoc *Document, revId string, timeout time.Duration)
| 1140 | } |
| 1141 | |
| 1142 | func 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 |
no test coverage detected