Adds expr functions for KV, KVV, Vars manipulation

- Adds/Refactors methods for Set, Merge, Filter, Delete
- Renames expr/Vars.Merge to MustMerge, updates its usage
- Appends kvFunctions to parser in pkg/expr
- Update/Fixes tests and example testable
This commit is contained in:
Vivek Patel
2021-05-21 06:58:52 +02:00
committed by Denis Arh
parent 28e1774cd2
commit 044d02bb76
14 changed files with 896 additions and 28 deletions
+1 -1
View File
@@ -66,7 +66,7 @@ func (gw *joinGateway) Exec(_ context.Context, r *ExecRequest) (ExecResponse, er
var merged *expr.Vars
for _, p := range gw.paths {
if gw.scopes[p] != nil {
merged = merged.Merge(gw.scopes[p])
merged = merged.MustMerge(gw.scopes[p])
}
}
+3 -3
View File
@@ -418,7 +418,7 @@ func (s *Session) worker(ctx context.Context) {
defer s.mux.Unlock()
// making sure result != nil
s.result = (&expr.Vars{}).Merge(st.scope)
s.result = (&expr.Vars{}).MustMerge(st.scope)
// Call event handler with completed status
s.eventHandler(SessionCompleted, st, s)
@@ -549,7 +549,7 @@ func (s *Session) exec(ctx context.Context, st *State) (err error) {
var (
result ExecResponse
scope = (&expr.Vars{}).Merge(st.scope)
scope = (&expr.Vars{}).MustMerge(st.scope)
currLoop = st.loopCurr()
@@ -635,7 +635,7 @@ func (s *Session) exec(ctx context.Context, st *State) (err error) {
// most common (successful) result
// session will continue with configured child steps
st.results = result
scope = scope.Merge(st.results)
scope = scope.MustMerge(st.results)
case *errHandler:
st.action = "error handler initialized"