MCPcopy
hub / github.com/grafana/dskit / casWithErr

Function casWithErr

kv/memberlist/memberlist_client_test.go:233–249  ·  view source on GitHub ↗
(ctx context.Context, kv *Client, key string, updateFn func(*data) (*data, bool, error))

Source from the content-addressed store, hash-verified

231}
232
233func casWithErr(ctx context.Context, kv *Client, key string, updateFn func(*data) (*data, bool, error)) error {
234 fn := func(in interface{}) (out interface{}, retry bool, err error) {
235 var r *data
236 if in != nil {
237 r = in.(*data)
238 }
239
240 d, rt, e := updateFn(r)
241 if d == nil {
242 // translate nil pointer to nil interface value
243 return nil, rt, e
244 }
245 return d, rt, e
246 }
247
248 return kv.CAS(ctx, key, fn)
249}
250
251func getLocalhostAddr() string {
252 return getLocalhostAddrs()[0]

Callers 6

casFunction · 0.85
TestCASErrorNoRetryFunction · 0.85
TestCASErrorWithRetriesFunction · 0.85
TestCASNoChangeFunction · 0.85

Calls 2

updateFnFunction · 0.85
CASMethod · 0.65

Tested by

no test coverage detected