You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// handle the SubscribeTarget-cache and crdCache in CRDWatcher, and remove watcher. only push into a chan named delSubscribeConnChan waiting for delete.
224
+
// 1. if there is no kind cached in current Connection, push subscribeConnInfo with an empty NamespaceApp into delSubscribeConnChan,
225
+
// then, will delete the watcher for CRD.
226
+
// 2. if the number of relation between Connection and SubscribeTarget < 1, then push subscribeConnInfo with current NamespaceApp into delSubscribeConnChan,
227
+
// then 1st, will delete the SubscribeTarget which is cached in current Connection
228
+
// 2nd, will delte the watcher for CRD if there's no kind cached in current Connection
// delSubscribeConnChan a chan for delete the SubscribeTarget-cache and crdCache in CRDWatcher, and remove watcher to stop watching.
254
+
vardelSubscribeConnChanchandelSubscribeConnInfo
255
+
256
+
typedelSubscribeConnInfostruct {
257
+
stream model.OpenSergoTransportStream
258
+
request*trpb.SubscribeRequest
259
+
namespaceApp model.NamespacedApp
260
+
kindstring
261
+
}
262
+
263
+
// delConn a goroutine contains the logic of delete the SubscribeTarget-cache and crdCache in CRDWatcher, and remove watcher.
264
+
//
265
+
// 1. at the beginning of current goroutine, should wait for the status of server is started.
266
+
//
267
+
// 2. when receive a delSubscribeConnInfo from delSubscribeConnChan, waiting a silence time to prevent inaccurate data statistics caused by network jitter.
268
+
//
269
+
// after the silence time, is the actually logic of deleting local cache and removing watcher.
270
+
func (c*ControlPlane) delConn() {
271
+
gofunc() {
272
+
// waiting for server is started.
273
+
for!c.server.IsStarted() {
274
+
time.Sleep(time.Duration(1) *time.Second)
275
+
}
276
+
277
+
// receive from delSubscribeConnChan
278
+
currDelConnInfo:=<-delSubscribeConnChan
279
+
namespaceApp:=currDelConnInfo.namespaceApp
280
+
kind:=currDelConnInfo.kind
281
+
request:=currDelConnInfo.request
282
+
stream:=currDelConnInfo.stream
283
+
284
+
// wait a silence for network jitter
285
+
// TODO make time of sleep is configurable
286
+
time.Sleep(time.Duration(5) *time.Second)
287
+
varerrerror
288
+
289
+
// RemoveSubscribeTarget from CRDWatcher
290
+
// if namespaceApp is not an empty struct, means that need to delete SubscribeTarget cache in CRDWatcher
0 commit comments