openStreamRequest issues the OpenStream request, but doesn't perform any error handling. Callers should generally use openStream() for error and retry handling
(vbID uint16)
| 498 | // openStreamRequest issues the OpenStream request, but doesn't perform any error handling. Callers |
| 499 | // should generally use openStream() for error and retry handling |
| 500 | func (dc *DCPClient) openStreamRequest(vbID uint16) error { |
| 501 | |
| 502 | vbMeta := dc.metadata.GetMeta(vbID) |
| 503 | |
| 504 | options := gocbcore.OpenStreamOptions{} |
| 505 | // Always use a collection-aware feed if supported |
| 506 | if dc.supportsCollections { |
| 507 | options.FilterOptions = &gocbcore.OpenStreamFilterOptions{CollectionIDs: dc.collectionIDs} |
| 508 | } |
| 509 | |
| 510 | // This has to be buffered so that Cancel() below doesn't lead to blocking in the callback. |
| 511 | // (If Cancel succeeds then it will lead to directly calling the callback). |
| 512 | openStreamError := make(chan error, 1) |
| 513 | openStreamCallback := func(f []gocbcore.FailoverEntry, err error) { |
| 514 | if err == nil { |
| 515 | err = dc.verifyFailoverLog(vbID, f) |
| 516 | if err == nil { |
| 517 | dc.metadata.SetFailoverEntries(vbID, f) |
| 518 | } |
| 519 | } |
| 520 | openStreamError <- err |
| 521 | } |
| 522 | |
| 523 | op, openErr := dc.agent.OpenStream(vbID, |
| 524 | memd.DcpStreamAddFlagActiveOnly, |
| 525 | vbMeta.VbUUID, |
| 526 | vbMeta.StartSeqNo, |
| 527 | vbMeta.EndSeqNo, |
| 528 | vbMeta.SnapStartSeqNo, |
| 529 | vbMeta.SnapEndSeqNo, |
| 530 | dc, |
| 531 | options, |
| 532 | openStreamCallback) |
| 533 | |
| 534 | if openErr != nil { |
| 535 | return openErr |
| 536 | } |
| 537 | |
| 538 | select { |
| 539 | case err := <-openStreamError: |
| 540 | return err |
| 541 | case <-time.After(openStreamTimeout): |
| 542 | op.Cancel() |
| 543 | <-openStreamError |
| 544 | return ErrTimeout |
| 545 | } |
| 546 | } |
| 547 | |
| 548 | // verifyFailoverLog checks for VbUUID changes when failOnRollback is set, and |
| 549 | // writes the failover log to the client metadata store. If previous VbUUID is zero, it's |
no test coverage detected