diff options
author | Manjunath Ranganathaiah <manjunath.ranganathaiah@intel.com> | 2020-03-16 20:27:26 +0000 |
---|---|---|
committer | Manjunath Ranganathaiah <manjunath.ranganathaiah@intel.com> | 2020-03-16 20:31:58 +0000 |
commit | b2c0a68d0abf7457d18c89b634265087758b63fd (patch) | |
tree | 43a441ab40df04c5adafc5be79068c9fd4b50c14 /src/orchestrator/pkg/rtcontext/rtcontext.go | |
parent | 9c63ce2a7b2b66b3e3fce5d1f553f327148df83f (diff) |
Add update interface to run time context library
Issue-ID: MULTICLOUD-1005
Change-Id: Ie6a8f5d83f56ea12107fdf81fe6819b1637b252a
Signed-off-by: Manjunath Ranganathaiah <manjunath.ranganathaiah@intel.com>
Diffstat (limited to 'src/orchestrator/pkg/rtcontext/rtcontext.go')
-rw-r--r-- | src/orchestrator/pkg/rtcontext/rtcontext.go | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/orchestrator/pkg/rtcontext/rtcontext.go b/src/orchestrator/pkg/rtcontext/rtcontext.go index 5c5bee13..e1f1c03b 100644 --- a/src/orchestrator/pkg/rtcontext/rtcontext.go +++ b/src/orchestrator/pkg/rtcontext/rtcontext.go @@ -42,6 +42,7 @@ type Rtcontext interface { RtcDeletePrefix(handle interface{}) (error) RtcGetHandles(handle interface{}) ([]interface{}, error) RtcGetValue(handle interface{}, value interface{}) (error) + RtcUpdateValue(handle interface{}, value interface{}) (error) } //Create context by assiging a new id @@ -220,3 +221,18 @@ func (rtc *RunTimeContext) RtcGetValue(handle interface{}, value interface{}) (e return nil } + +// Update the value of a given handle +func (rtc *RunTimeContext) RtcUpdateValue(handle interface{}, value interface{}) (error) { + str := fmt.Sprintf("%v", handle) + sid := fmt.Sprintf("%v", rtc.cid) + if !strings.HasPrefix(str, sid) { + return pkgerrors.Errorf("Not a valid run time context handle") + } + err := contextdb.Db.Put(str, value) + if err != nil { + return pkgerrors.Errorf("Error updating run time context value: %s", err.Error()) + } + return nil + +} |