MCPcopy Create free account
hub / github.com/google/go-cloud / WatchVariable

Method WatchVariable

runtimevar/awsparamstore/awsparamstore.go:259–286  ·  view source on GitHub ↗
(ctx context.Context, prev driver.State)

Source from the content-addressed store, hash-verified

257}
258
259func (w *watcher) WatchVariable(ctx context.Context, prev driver.State) (driver.State, time.Duration) {
260 lastVersion := int64(-1)
261 if prev != nil {
262 lastVersion = prev.(*state).version
263 }
264
265 // GetParameter from S3 to get the current value and version.
266 newVersion, newVal, newLastModified, rawGet, err := getParameter(ctx, w.client, w.name)
267 if err != nil {
268 return errorState(err, prev), w.wait
269 }
270 if newVersion == lastVersion {
271 // Version hasn't changed, so no change; return nil.
272 return nil, w.wait
273 }
274
275 // New value (or at least, new version). Decode it.
276 val, err := w.decoder.Decode(ctx, newVal)
277 if err != nil {
278 return errorState(err, prev), w.wait
279 }
280 return &state{
281 val: val,
282 rawGet: rawGet,
283 updateTime: newLastModified,
284 version: newVersion,
285 }, w.wait
286}
287
288// Close implements driver.Close.
289func (w *watcher) Close() error {

Callers

nothing calls this directly

Calls 3

getParameterFunction · 0.85
errorStateFunction · 0.70
DecodeMethod · 0.45

Tested by

no test coverage detected