@@ -42,7 +42,7 @@ type Client interface {
42
42
GetFailOverLogs (vbID uint16 ) ([]gocbcore.FailoverEntry , error )
43
43
OpenStream (vbID uint16 , collectionIDs map [uint32 ]string , offset * models.Offset , observer Observer ) error
44
44
CloseStream (vbID uint16 ) error
45
- GetCollectionIDs (scopeName string , collectionNames []string ) map [uint32 ]string
45
+ GetCollectionIDs (scopeName string , collectionNames []string ) ( map [uint32 ]string , error )
46
46
GetAgentConfigSnapshot () (* gocbcore.ConfigSnapshot , error )
47
47
GetDcpAgentConfigSnapshot () (* gocbcore.ConfigSnapshot , error )
48
48
GetAgentQueues () []* models.AgentQueue
@@ -469,6 +469,7 @@ func (s *client) DcpClose() {
469
469
logger .Log .Info ("dcp connection closed %s" , s .config .Hosts )
470
470
}
471
471
472
+ //nolint:funlen
472
473
func (s * client ) GetVBucketSeqNos (awareCollection bool ) (* wrapper.ConcurrentSwissMap [uint16 , uint64 ], error ) {
473
474
snapshot , err := s .GetDcpAgentConfigSnapshot ()
474
475
if err != nil {
@@ -486,7 +487,10 @@ func (s *client) GetVBucketSeqNos(awareCollection bool) (*wrapper.ConcurrentSwis
486
487
487
488
hasCollectionSupport := awareCollection && s .dcpAgent .HasCollectionsSupport ()
488
489
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
+ }
490
494
collectionIDs := make ([]uint32 , 0 , len (cIds ))
491
495
for collectionID := range cIds {
492
496
collectionIDs = append (collectionIDs , collectionID )
@@ -759,7 +763,7 @@ func (s *client) getCollectionID(ctx context.Context, scopeName string, collecti
759
763
scopeName ,
760
764
collectionName ,
761
765
gocbcore.GetCollectionIDOptions {
762
- Deadline : time .Now ().Add (time .Second * 5 ),
766
+ Deadline : time .Now ().Add (time .Second * 30 ),
763
767
RetryStrategy : gocbcore .NewBestEffortRetryStrategy (nil ),
764
768
},
765
769
func (result * gocbcore.GetCollectionIDResult , err error ) {
@@ -780,8 +784,8 @@ func (s *client) getCollectionID(ctx context.Context, scopeName string, collecti
780
784
return collectionID , <- ch
781
785
}
782
786
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 )
785
789
defer cancel ()
786
790
787
791
collectionIDs := map [uint32 ]string {}
@@ -791,14 +795,14 @@ func (s *client) GetCollectionIDs(scopeName string, collectionNames []string) ma
791
795
collectionID , err := s .getCollectionID (ctx , scopeName , collectionName )
792
796
if err != nil {
793
797
logger .Log .Error ("error while get collection ids, err: %v" , err )
794
- panic ( err )
798
+ return nil , err
795
799
}
796
800
797
801
collectionIDs [collectionID ] = collectionName
798
802
}
799
803
}
800
804
801
- return collectionIDs
805
+ return collectionIDs , nil
802
806
}
803
807
804
808
func NewClient (config * config.Dcp ) Client {
0 commit comments