MCPcopy
hub / github.com/kubernetes/client-go / Add

Method Add

tools/cache/undelta_store.go:45–51  ·  view source on GitHub ↗

Note about thread safety. The Store implementation (cache.cache) uses a lock for all methods. In the functions below, the lock gets released and reacquired betweend the {Add,Delete,etc} and the List. So, the following can happen, resulting in two identical calls to PushFunc. time thread

(obj interface{})

Source from the content-addressed store, hash-verified

43// 5 Store.List() -> [a,b]
44
45func (u *UndeltaStore) Add(obj interface{}) error {
46 if err := u.Store.Add(obj); err != nil {
47 return err
48 }
49 u.PushFunc(u.Store.List())
50 return nil
51}
52
53func (u *UndeltaStore) Update(obj interface{}) error {
54 if err := u.Store.Update(obj); err != nil {

Callers 2

TestUpdateCallsPushFunction · 0.95
TestDeleteCallsPushFunction · 0.95

Calls 2

AddMethod · 0.65
ListMethod · 0.65

Tested by 2

TestUpdateCallsPushFunction · 0.76
TestDeleteCallsPushFunction · 0.76