@@ -42,7 +42,7 @@ type Client interface {
4242 GetFailOverLogs (vbID uint16 ) ([]gocbcore.FailoverEntry , error )
4343 OpenStream (vbID uint16 , collectionIDs map [uint32 ]string , offset * models.Offset , observer Observer ) error
4444 CloseStream (vbID uint16 ) error
45- GetCollectionIDs (scopeName string , collectionNames []string ) map [uint32 ]string
45+ GetCollectionIDs (scopeName string , collectionNames []string ) ( map [uint32 ]string , error )
4646 GetAgentConfigSnapshot () (* gocbcore.ConfigSnapshot , error )
4747 GetDcpAgentConfigSnapshot () (* gocbcore.ConfigSnapshot , error )
4848 GetAgentQueues () []* models.AgentQueue
@@ -469,6 +469,7 @@ func (s *client) DcpClose() {
469469 logger .Log .Info ("dcp connection closed %s" , s .config .Hosts )
470470}
471471
472+ //nolint:funlen
472473func (s * client ) GetVBucketSeqNos (awareCollection bool ) (* wrapper.ConcurrentSwissMap [uint16 , uint64 ], error ) {
473474 snapshot , err := s .GetDcpAgentConfigSnapshot ()
474475 if err != nil {
@@ -486,7 +487,10 @@ func (s *client) GetVBucketSeqNos(awareCollection bool) (*wrapper.ConcurrentSwis
486487
487488 hasCollectionSupport := awareCollection && s .dcpAgent .HasCollectionsSupport ()
488489
489- cIds := s .GetCollectionIDs (s .config .ScopeName , s .config .CollectionNames )
490+ cIds , err := s .GetCollectionIDs (s .config .ScopeName , s .config .CollectionNames )
491+ if err != nil {
492+ return nil , err
493+ }
490494 collectionIDs := make ([]uint32 , 0 , len (cIds ))
491495 for collectionID := range cIds {
492496 collectionIDs = append (collectionIDs , collectionID )
@@ -759,7 +763,7 @@ func (s *client) getCollectionID(ctx context.Context, scopeName string, collecti
759763 scopeName ,
760764 collectionName ,
761765 gocbcore.GetCollectionIDOptions {
762- Deadline : time .Now ().Add (time .Second * 5 ),
766+ Deadline : time .Now ().Add (time .Second * 30 ),
763767 RetryStrategy : gocbcore .NewBestEffortRetryStrategy (nil ),
764768 },
765769 func (result * gocbcore.GetCollectionIDResult , err error ) {
@@ -780,8 +784,8 @@ func (s *client) getCollectionID(ctx context.Context, scopeName string, collecti
780784 return collectionID , <- ch
781785}
782786
783- func (s * client ) GetCollectionIDs (scopeName string , collectionNames []string ) map [uint32 ]string {
784- ctx , cancel := context .WithTimeout (context .Background (), time .Second * 10 )
787+ func (s * client ) GetCollectionIDs (scopeName string , collectionNames []string ) ( map [uint32 ]string , error ) {
788+ ctx , cancel := context .WithTimeout (context .Background (), time .Minute )
785789 defer cancel ()
786790
787791 collectionIDs := map [uint32 ]string {}
@@ -791,14 +795,14 @@ func (s *client) GetCollectionIDs(scopeName string, collectionNames []string) ma
791795 collectionID , err := s .getCollectionID (ctx , scopeName , collectionName )
792796 if err != nil {
793797 logger .Log .Error ("error while get collection ids, err: %v" , err )
794- panic ( err )
798+ return nil , err
795799 }
796800
797801 collectionIDs [collectionID ] = collectionName
798802 }
799803 }
800804
801- return collectionIDs
805+ return collectionIDs , nil
802806}
803807
804808func NewClient (config * config.Dcp ) Client {
0 commit comments