Repository: kubernetes/kubernetes
File: staging/src/k8s.io/client-go/tools/cache/the_real_fifo.go (Go)

Code before:

package cache

import (
	"fmt"
	"sync"
	"time"

	utilruntime "k8s.io/apimachinery/pkg/util/runtime"
	"k8s.io/apimachinery/pkg/util/sets"
	utiltrace "k8s.io/utils/trace"
)

// RealFIFOOptions is the configuration parameters for RealFIFO.
type RealFIFOOptions struct {
	// KeyFunction is used to figure out what key an object should have. (It's
	// exposed in the returned RealFIFO's keyOf() method, with additional
	// handling around deleted objects and queue state).
	// Optional, the default is MetaNamespaceKeyFunc.
	KeyFunction KeyFunc

	// KnownObjects is expected to return a list of keys that the consumer of
	// this queue "knows about". It is used to decide which items are missing
	// when Replace() is called; 'Deleted' deltas are produced for the missing items.
	// KnownObjects is required if AtomicEvents is false since it is used to
	// query the state of the internal store.
	KnownObjects KeyListerGetter

	// If set, will be called for objects before enqueueing them. Please
	// see the comment on TransformFunc for details.
	Transformer TransformFunc

	// AtomicEvents is used to specify whether the RealFIFO will emit events
	// atomically or not. If it is set, a single event will be emitted
	// atomically for Replace and Resync operations.
	// If AtomicEvents is true, KnownObjects must be nil.
	AtomicEvents bool
}

const (
	defaultBatchSize = 1000
)

var _ QueueWithBatch = &RealFIFO{}

// RealFIFO is a Queue in which every notification from the Reflector is passed
// in order to the Queue via Pop.
// This means that it
// 1. delivers notifications for items that have been deleted
// 2. delivers multiple notifications per item instead of simply the most recent value
type RealFIFO struct {

Review comment (suggestion):
```suggestion
	// query the state of the internal store for Replace and Resync handling.
```

Code after:

package cache

import (
	"fmt"
	"sync"
	"time"

	utilruntime "k8s.io/apimachinery/pkg/util/runtime"
	"k8s.io/apimachinery/pkg/util/sets"
	utiltrace "k8s.io/utils/trace"
)

// RealFIFOOptions is the configuration parameters for RealFIFO.
type RealFIFOOptions struct {
	// KeyFunction is used to figure out what key an object should have. (It's
	// exposed in the returned RealFIFO's keyOf() method, with additional
	// handling around deleted objects and queue state).
	// Optional, the default is MetaNamespaceKeyFunc.
	KeyFunction KeyFunc

	// KnownObjects is expected to return a list of keys that the consumer of
	// this queue "knows about". It is used to decide which items are missing
	// when Replace() is called; 'Deleted' deltas are produced for the missing items.
	// KnownObjects is required if AtomicEvents is false since it is used to
	// query the state of the internal store for Replace and Resync handling.
	KnownObjects KeyListerGetter

	// If set, will be called for objects before enqueueing them. Please
	// see the comment on TransformFunc for details.
	Transformer TransformFunc

	// AtomicEvents is used to specify whether the RealFIFO will emit events
	// atomically or not. If it is set, a single event will be emitted
	// atomically for Replace and Resync operations.
	// If AtomicEvents is true, KnownObjects must be nil.
	AtomicEvents bool
}

const (
	defaultBatchSize = 1000
)

var _ QueueWithBatch = &RealFIFO{}

// RealFIFO is a Queue in which every notification from the Reflector is passed
// in order to the Queue via Pop.
// This means that it
// 1. delivers notifications for items that have been deleted
// 2. delivers multiple notifications per item instead of simply the most recent value
type RealFIFO struct {