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

Method openStreamRequest

base/dcp_client.go:500–546  ·  view source on GitHub ↗

openStreamRequest issues the OpenStream request, but doesn't perform any error handling. Callers should generally use openStream() for error and retry handling

(vbID uint16)

Source from the content-addressed store, hash-verified

498// openStreamRequest issues the OpenStream request, but doesn't perform any error handling. Callers
499// should generally use openStream() for error and retry handling
500func (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

Callers 1

openStreamMethod · 0.95

Calls 5

verifyFailoverLogMethod · 0.95
AfterMethod · 0.80
CancelMethod · 0.80
GetMetaMethod · 0.65
SetFailoverEntriesMethod · 0.65

Tested by

no test coverage detected