WaitForIndexing does a busy wait for indexing to finish or the context to error out, if the input flag shouldWait is true. Otherwise, it just returns nil straight away. If the context errors, it returns that error. TODO(aman): we should return an error if the indexing fails
(ctx context.Context, shouldWait bool)
| 249 | // If the context errors, it returns that error. |
| 250 | // TODO(aman): we should return an error if the indexing fails |
| 251 | func WaitForIndexing(ctx context.Context, shouldWait bool) error { |
| 252 | for shouldWait { |
| 253 | if ctx.Err() != nil { |
| 254 | return ctx.Err() |
| 255 | } |
| 256 | if !schema.State().IndexingInProgress() { |
| 257 | break |
| 258 | } |
| 259 | time.Sleep(time.Second * 2) |
| 260 | } |
| 261 | return nil |
| 262 | } |
| 263 | |
| 264 | // isGroupOneLeader returns true if the current server is the leader of Group One, |
| 265 | // it returns false otherwise. |
no test coverage detected