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

Code before:
// do not do anything that will take a long time.
type TransformFunc func(interface{}) (interface{}, error)

// DeltaType is the type of a change (addition, deletion, etc)
type DeltaType string

// Change type definition
const (
	Added   DeltaType = "Added"
	Updated DeltaType = "Updated"
	Deleted DeltaType = "Deleted"
	// Replaced is emitted when we encountered watch errors and had to do a
	// relist. We don't know if the replaced object has changed.
	//
	// NOTE: Previous versions of DeltaFIFO would use Sync for Replace events
	// as well. Hence, Replaced is only emitted when the option
	// EmitDeltaTypeReplaced is true.
	Replaced DeltaType = "Replaced"
	// ReplacedList is emitted when we encountered watch errors and had to do
	// a relist. This is the same reason as Replaced but will be emitted instead
	// when the FIFO supports atomic replacement. This event will return the
	// full list of replaced items instead of a single object.
	ReplacedList DeltaType = "ReplacedList"
	// Sync is for synthetic events during a periodic resync.
	Sync DeltaType = "Sync"
	// SyncAll is to trigger a resync of the entire queue.
	SyncAll DeltaType = "SyncAll"
)

// Delta is a member of Deltas (a list of Delta objects) which
// in its turn is the type stored by a DeltaFIFO. It tells you what
// change happened, and the object's state after* that change.
//
// [*] Unless the change is a deletion, and then you'll get the final
// state of the object before it was deleted.
type Delta struct {
	Type   DeltaType
	Object interface{}
}

// Deltas is a list of one or more 'Delta's to an individual object.
// The oldest delta is at index 0, the newest delta is the last one.
type Deltas []Delta

// NewDeltaFIFO returns a Queue which can be used to process changes to items.
//
// keyFunc is used to figure out what key an object should have. (It is
// exposed in the returned DeltaFIFO's KeyOf() method, with additional handling
// around deleted objects and queue state).
//
// 'knownObjects' may be supplied to modify the behavior of Delete,

Review comment (suggestion):
clarify in docs and check in code what the object for this delta type is (could make a dedicated type, even if it's empty for now)

Code after:
// do not do anything that will take a long time.
type TransformFunc func(interface{}) (interface{}, error)

// DeltaType is the type of a change (addition, deletion, etc)
type DeltaType string

// Change type definition
const (
	Added   DeltaType = "Added"
	Updated DeltaType = "Updated"
	Deleted DeltaType = "Deleted"
	// Replaced is emitted when we encountered watch errors and had to do a
	// relist, or on initial listing of objects. We don't know if the replaced
	// object has changed.
	//
	// NOTE: Previous versions of DeltaFIFO would use Sync for Replace events
	// as well. Hence, Replaced is only emitted when the option
	// EmitDeltaTypeReplaced is true.
	Replaced DeltaType = "Replaced"
	// ReplacedAll is emitted when we encountered watch errors and had to do
	// a relist, or on initial listing of objects. This is the same reason as
	// Replaced but will be emitted instead when the FIFO supports atomic
	// replacement. This event will return the full list of replaced items
	// instead of a single object.
	ReplacedAll DeltaType = "ReplacedAll"
	// Sync is for synthetic events during a periodic resync.
	Sync DeltaType = "Sync"
	// SyncAll indicates all known objects should be reprocessed.
	// This event contains an object of type SyncAllInfo.
	SyncAll DeltaType = "SyncAll"
)

// Delta is a member of Deltas (a list of Delta objects) which
// in its turn is the type stored by a DeltaFIFO. It tells you what
// change happened, and the object's state after* that change.
//
// [*] Unless the change is a deletion, and then you'll get the final
// state of the object before it was deleted.
type Delta struct {
	Type   DeltaType
	Object interface{}
}

// Deltas is a list of one or more 'Delta's to an individual object.
// The oldest delta is at index 0, the newest delta is the last one.
type Deltas []Delta

// NewDeltaFIFO returns a Queue which can be used to process changes to items.
//
// keyFunc is used to figure out what key an object should have. (It is
// exposed in the returned DeltaFIFO's KeyOf() method, with additional handling