예제 #1
0
func NewCache(bufferDuration, gcDuration time.Duration) Cache {
	rc := &realCache{
		pods:           make(map[string]*podElement),
		nodes:          make(map[string]*nodeElement),
		events:         store.NewGCStore(store.NewTimeStore(), bufferDuration),
		eventUIDs:      make(map[string]struct{}),
		bufferDuration: bufferDuration,
	}
	go util.Until(rc.runGC, gcDuration, util.NeverStop)
	return rc
}
예제 #2
0
// TestNewInfoType tests both flows of the InfoType constructor.
func TestNewInfoType(t *testing.T) {
	var (
		metrics = make(map[string]*store.TimeStore)
		labels  = make(map[string]string)
	)
	new_store := store.NewGCStore(store.NewTimeStore(), time.Hour)
	metrics["test"] = &new_store
	labels["name"] = "test"
	assert := assert.New(t)

	// Invocation with no parameters
	new_infotype := newInfoType(nil, nil)
	assert.Empty(new_infotype.Metrics)
	assert.Empty(new_infotype.Labels)

	// Invocation with both parameters
	new_infotype = newInfoType(metrics, labels)
	assert.Equal(new_infotype.Metrics, metrics)
	assert.Equal(new_infotype.Labels, labels)
}
예제 #3
0
// newTimeStore returns a new GCStore.
// Meant to be passed to newRealCluster.
func newTimeStore() store.TimeStore {
	return store.NewGCStore(store.NewTimeStore(), time.Hour)
}
예제 #4
0
func (rc *realCache) newContainerElement() *containerElement {
	return &containerElement{
		metrics: store.NewGCStore(store.NewTimeStore(), rc.bufferDuration),
	}
}