MCPcopy Create free account
hub / github.com/couchbase/cbft / RunSourcePartitionSeqs

Function RunSourcePartitionSeqs

ns_server.go:1034–1135  ·  view source on GitHub ↗
(options map[string]string, stopCh chan struct{})

Source from the content-addressed store, hash-verified

1032}
1033
1034func RunSourcePartitionSeqs(options map[string]string, stopCh chan struct{}) {
1035 sourcePartitionSeqsSleep := SourcePartitionSeqsSleepDefault
1036 v, exists := options["sourcePartitionSeqsSleepMS"]
1037 if exists {
1038 sourcePartitionSeqsSleepMS, err := strconv.Atoi(v)
1039 if err != nil {
1040 log.Warnf("ns_server: parse sourcePartitionSeqsSleepMS: %q,"+
1041 " err: %v", v, err)
1042 } else {
1043 sourcePartitionSeqsSleep = time.Millisecond *
1044 time.Duration(sourcePartitionSeqsSleepMS)
1045 }
1046 }
1047
1048 sourcePartitionSeqsCacheTimeout := SourcePartitionSeqsCacheTimeoutDefault
1049 v, exists = options["sourcePartitionSeqsCacheTimeoutMS"]
1050 if exists {
1051 sourcePartitionSeqsCacheTimeoutMS, err := strconv.Atoi(v)
1052 if err != nil {
1053 log.Warnf("ns_server: parse sourcePartitionSeqsCacheTimeoutMS: %q,"+
1054 " err: %v", v, err)
1055 } else {
1056 sourcePartitionSeqsCacheTimeout = time.Millisecond *
1057 time.Duration(sourcePartitionSeqsCacheTimeoutMS)
1058 }
1059 }
1060
1061 m := &mapSourcePartitionSeqsM
1062
1063 for {
1064 select {
1065 case <-stopCh:
1066 return
1067 case <-time.After(sourcePartitionSeqsSleep):
1068 // NO-OP.
1069 }
1070
1071 m.Lock()
1072 var sourceSpecs []SourceSpec // Snapshot the wanted sourceSpecs.
1073 for sourceSpec := range mapSourcePartitionSeqs {
1074 sourceSpecs = append(sourceSpecs, sourceSpec)
1075 }
1076 m.Unlock()
1077
1078 for _, sourceSpec := range sourceSpecs {
1079 select {
1080 case <-stopCh:
1081 return
1082 default:
1083 // NO-OP.
1084 }
1085
1086 m.Lock()
1087 s := SourcePartitionSeqs{}
1088 v, exists := mapSourcePartitionSeqs[sourceSpec]
1089 if exists && v != nil {
1090 s = *v // Copy fields.
1091 }

Callers 1

initNsServerCachingFunction · 0.85

Calls 1

PartitionSeqsMethod · 0.65

Tested by

no test coverage detected