github.com/cilium/cilium@v1.16.2/pkg/k8s/synced/cache_status.go (about)

     1  // SPDX-License-Identifier: Apache-2.0
     2  // Copyright Authors of Cilium
     3  
     4  package synced
     5  
     6  // CacheStatus allows waiting for k8s caches to synchronize.
     7  type CacheStatus chan struct{}
     8  
     9  // Sychronized returns true if caches have been synchronized at least once.
    10  //
    11  // Returns true for an uninitialized [CacheStatus].
    12  func (cs CacheStatus) Synchronized() bool {
    13  	if cs == nil {
    14  		return true
    15  	}
    16  
    17  	select {
    18  	case <-cs:
    19  		return true
    20  	default:
    21  		return false
    22  	}
    23  }