blob: 08c0359e46cd90fc09905812f5fe558dbe92fb7b [file] [log] [blame]
khenaidoobf6e7bb2018-08-14 22:27:29 -04001/*
2 * Copyright 2018-present Open Networking Foundation
3
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7
8 * http://www.apache.org/licenses/LICENSE-2.0
9
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
Stephane Barbariedc5022d2018-11-19 15:21:44 -050016
Stephane Barbarie4a2564d2018-07-26 11:02:58 -040017package model
18
19import (
Stephane Barbarie694e2b92018-09-07 12:17:36 -040020 "crypto/md5"
Stephane Barbarie694e2b92018-09-07 12:17:36 -040021 "errors"
khenaidoob9203542018-09-17 22:56:37 -040022 "fmt"
23 "github.com/opencord/voltha-go/common/log"
24 "reflect"
Stephane Barbarie694e2b92018-09-07 12:17:36 -040025 "runtime"
khenaidoob9203542018-09-17 22:56:37 -040026 "strings"
Stephane Barbariea188d942018-10-16 16:43:04 -040027 "sync"
Stephane Barbarie4a2564d2018-07-26 11:02:58 -040028)
29
Stephane Barbariedc5022d2018-11-19 15:21:44 -050030// OperationContext holds details on the information used during an operation
Stephane Barbarieec0919b2018-09-05 14:14:29 -040031type OperationContext struct {
32 Path string
33 Data interface{}
34 FieldName string
35 ChildKey string
36}
37
Stephane Barbariedc5022d2018-11-19 15:21:44 -050038// NewOperationContext instantiates a new OperationContext structure
Stephane Barbarieec0919b2018-09-05 14:14:29 -040039func NewOperationContext(path string, data interface{}, fieldName string, childKey string) *OperationContext {
40 oc := &OperationContext{
41 Path: path,
42 Data: data,
43 FieldName: fieldName,
44 ChildKey: childKey,
45 }
46 return oc
47}
48
Stephane Barbariedc5022d2018-11-19 15:21:44 -050049// Update applies new data to the context structure
Stephane Barbarieec0919b2018-09-05 14:14:29 -040050func (oc *OperationContext) Update(data interface{}) *OperationContext {
51 oc.Data = data
52 return oc
53}
54
Stephane Barbariedc5022d2018-11-19 15:21:44 -050055// Proxy holds the information for a specific location with the data model
Stephane Barbarie4a2564d2018-07-26 11:02:58 -040056type Proxy struct {
Stephane Barbariedc5022d2018-11-19 15:21:44 -050057 sync.RWMutex
Stephane Barbarie1ab43272018-12-08 21:42:13 -050058 Root *root
59 Node *node
60 ParentNode *node
61 Path string
62 FullPath string
63 Exclusive bool
64 Callbacks map[CallbackType]map[string]*CallbackTuple
Stephane Barbarie4a2564d2018-07-26 11:02:58 -040065}
66
Stephane Barbariedc5022d2018-11-19 15:21:44 -050067// NewProxy instantiates a new proxy to a specific location
Stephane Barbarie1ab43272018-12-08 21:42:13 -050068func NewProxy(root *root, node *node, parentNode *node, path string, fullPath string, exclusive bool) *Proxy {
Stephane Barbariedc5022d2018-11-19 15:21:44 -050069 callbacks := make(map[CallbackType]map[string]*CallbackTuple)
Stephane Barbariea188d942018-10-16 16:43:04 -040070 if fullPath == "/" {
71 fullPath = ""
72 }
Stephane Barbarie4a2564d2018-07-26 11:02:58 -040073 p := &Proxy{
Stephane Barbarie1ab43272018-12-08 21:42:13 -050074 Root: root,
75 Node: node,
76 ParentNode: parentNode,
77 Exclusive: exclusive,
78 Path: path,
79 FullPath: fullPath,
80 Callbacks: callbacks,
Stephane Barbarie4a2564d2018-07-26 11:02:58 -040081 }
82 return p
83}
84
Stephane Barbariedc5022d2018-11-19 15:21:44 -050085// GetRoot returns the root attribute of the proxy
86func (p *Proxy) GetRoot() *root {
Stephane Barbariedc5022d2018-11-19 15:21:44 -050087 return p.Root
88}
89
90// getPath returns the path attribute of the proxy
91func (p *Proxy) getPath() string {
Stephane Barbariedc5022d2018-11-19 15:21:44 -050092 return p.Path
93}
94
95// getFullPath returns the full path attribute of the proxy
96func (p *Proxy) getFullPath() string {
Stephane Barbariedc5022d2018-11-19 15:21:44 -050097 return p.FullPath
98}
99
100// getCallbacks returns the full list of callbacks associated to the proxy
101func (p *Proxy) getCallbacks(callbackType CallbackType) map[string]*CallbackTuple {
Stephane Barbariedc5022d2018-11-19 15:21:44 -0500102 if cb, exists := p.Callbacks[callbackType]; exists {
103 return cb
104 }
105 return nil
106}
107
108// getCallback returns a specific callback matching the type and function hash
109func (p *Proxy) getCallback(callbackType CallbackType, funcHash string) *CallbackTuple {
Stephane Barbariedc5022d2018-11-19 15:21:44 -0500110 if tuple, exists := p.Callbacks[callbackType][funcHash]; exists {
111 return tuple
112 }
113 return nil
114}
115
116// setCallbacks applies a callbacks list to a type
117func (p *Proxy) setCallbacks(callbackType CallbackType, callbacks map[string]*CallbackTuple) {
118 p.Lock()
119 defer p.Unlock()
120 p.Callbacks[callbackType] = callbacks
121}
122
123// setCallback applies a callback to a type and hash value
124func (p *Proxy) setCallback(callbackType CallbackType, funcHash string, tuple *CallbackTuple) {
125 p.Lock()
126 defer p.Unlock()
127 p.Callbacks[callbackType][funcHash] = tuple
128}
129
130// DeleteCallback removes a callback matching the type and hash
131func (p *Proxy) DeleteCallback(callbackType CallbackType, funcHash string) {
132 p.Lock()
133 defer p.Unlock()
134 delete(p.Callbacks[callbackType], funcHash)
135}
136
137// parseForControlledPath verifies if a proxy path matches a pattern
138// for locations that need to be access controlled.
Stephane Barbariea188d942018-10-16 16:43:04 -0400139func (p *Proxy) parseForControlledPath(path string) (pathLock string, controlled bool) {
Stephane Barbariedc5022d2018-11-19 15:21:44 -0500140 // TODO: Add other path prefixes that may need control
Stephane Barbarie1ab43272018-12-08 21:42:13 -0500141 if strings.HasPrefix(path, "/devices") ||
142 strings.HasPrefix(path, "/logical_devices") ||
143 strings.HasPrefix(path, "/adapters") {
144
Stephane Barbariea188d942018-10-16 16:43:04 -0400145 split := strings.SplitN(path, "/", -1)
146 switch len(split) {
147 case 2:
148 controlled = false
149 pathLock = ""
150 break
151 case 3:
152 fallthrough
153 default:
154 pathLock = fmt.Sprintf("%s/%s", split[1], split[2])
155 controlled = true
156 }
157 }
158 return pathLock, controlled
159}
160
Stephane Barbarieaa467942019-02-06 14:09:44 -0500161// List will retrieve information from the data model at the specified path location
162// A list operation will force access to persistence storage
163func (p *Proxy) List(path string, depth int, deep bool, txid string) interface{} {
164 var effectivePath string
165 if path == "/" {
166 effectivePath = p.getFullPath()
167 } else {
168 effectivePath = p.getFullPath() + path
169 }
170
171 pathLock, controlled := p.parseForControlledPath(effectivePath)
172
173 log.Debugf("Path: %s, Effective: %s, PathLock: %s", path, effectivePath, pathLock)
174
175 pac := PAC().ReservePath(effectivePath, p, pathLock)
176 defer PAC().ReleasePath(pathLock)
177 pac.SetProxy(p)
178
179 rv := pac.List(path, depth, deep, txid, controlled)
180
181 return rv
182}
183
184
Stephane Barbariedc5022d2018-11-19 15:21:44 -0500185// Get will retrieve information from the data model at the specified path location
Stephane Barbarie4a2564d2018-07-26 11:02:58 -0400186func (p *Proxy) Get(path string, depth int, deep bool, txid string) interface{} {
Stephane Barbariea188d942018-10-16 16:43:04 -0400187 var effectivePath string
188 if path == "/" {
Stephane Barbariedc5022d2018-11-19 15:21:44 -0500189 effectivePath = p.getFullPath()
Stephane Barbariea188d942018-10-16 16:43:04 -0400190 } else {
Stephane Barbariedc5022d2018-11-19 15:21:44 -0500191 effectivePath = p.getFullPath() + path
Stephane Barbariea188d942018-10-16 16:43:04 -0400192 }
193
194 pathLock, controlled := p.parseForControlledPath(effectivePath)
195
Stephane Barbariedc5022d2018-11-19 15:21:44 -0500196 log.Debugf("Path: %s, Effective: %s, PathLock: %s", path, effectivePath, pathLock)
Stephane Barbariea188d942018-10-16 16:43:04 -0400197
Stephane Barbariedc5022d2018-11-19 15:21:44 -0500198 pac := PAC().ReservePath(effectivePath, p, pathLock)
199 defer PAC().ReleasePath(pathLock)
200 pac.SetProxy(p)
Stephane Barbariea188d942018-10-16 16:43:04 -0400201
Stephane Barbariedc5022d2018-11-19 15:21:44 -0500202 rv := pac.Get(path, depth, deep, txid, controlled)
203
204 return rv
Stephane Barbarie4a2564d2018-07-26 11:02:58 -0400205}
206
Stephane Barbariedc5022d2018-11-19 15:21:44 -0500207// Update will modify information in the data model at the specified location with the provided data
Stephane Barbarie4a2564d2018-07-26 11:02:58 -0400208func (p *Proxy) Update(path string, data interface{}, strict bool, txid string) interface{} {
209 if !strings.HasPrefix(path, "/") {
Stephane Barbarie8c48b5c2018-10-02 09:45:17 -0400210 log.Errorf("invalid path: %s", path)
Stephane Barbarie4a2564d2018-07-26 11:02:58 -0400211 return nil
212 }
213 var fullPath string
Stephane Barbariea188d942018-10-16 16:43:04 -0400214 var effectivePath string
Stephane Barbarie4a2564d2018-07-26 11:02:58 -0400215 if path == "/" {
Stephane Barbariedc5022d2018-11-19 15:21:44 -0500216 fullPath = p.getPath()
217 effectivePath = p.getFullPath()
Stephane Barbarie4a2564d2018-07-26 11:02:58 -0400218 } else {
Stephane Barbariedc5022d2018-11-19 15:21:44 -0500219 fullPath = p.getPath() + path
Stephane Barbarie1039ec42019-02-04 10:43:16 -0500220 effectivePath = p.getFullPath() + path
Stephane Barbarie4a2564d2018-07-26 11:02:58 -0400221 }
Stephane Barbarie126101e2018-10-11 16:18:48 -0400222
Stephane Barbariea188d942018-10-16 16:43:04 -0400223 pathLock, controlled := p.parseForControlledPath(effectivePath)
224
Stephane Barbariedc5022d2018-11-19 15:21:44 -0500225 log.Debugf("Path: %s, Effective: %s, Full: %s, PathLock: %s", path, effectivePath, fullPath, pathLock)
Stephane Barbariea188d942018-10-16 16:43:04 -0400226
Stephane Barbariedc5022d2018-11-19 15:21:44 -0500227 pac := PAC().ReservePath(effectivePath, p, pathLock)
228 defer PAC().ReleasePath(pathLock)
229 pac.SetProxy(p)
Stephane Barbariea188d942018-10-16 16:43:04 -0400230
Stephane Barbariedc5022d2018-11-19 15:21:44 -0500231 return pac.Update(fullPath, data, strict, txid, controlled)
Stephane Barbarie4a2564d2018-07-26 11:02:58 -0400232}
233
Stephane Barbariedc5022d2018-11-19 15:21:44 -0500234// AddWithID will insert new data at specified location.
235// This method also allows the user to specify the ID of the data entry to ensure
236// that access control is active while inserting the information.
237func (p *Proxy) AddWithID(path string, id string, data interface{}, txid string) interface{} {
238 if !strings.HasPrefix(path, "/") {
239 log.Errorf("invalid path: %s", path)
240 return nil
241 }
242 var fullPath string
243 var effectivePath string
244 if path == "/" {
245 fullPath = p.getPath()
246 effectivePath = p.getFullPath()
247 } else {
248 fullPath = p.getPath() + path
249 effectivePath = p.getFullPath() + path + "/" + id
250 }
251
252 pathLock, controlled := p.parseForControlledPath(effectivePath)
253
254 log.Debugf("Path: %s, Effective: %s, Full: %s, PathLock: %s", path, effectivePath, fullPath, pathLock)
255
256 pac := PAC().ReservePath(path, p, pathLock)
257 defer PAC().ReleasePath(pathLock)
258 pac.SetProxy(p)
259
260 return pac.Add(fullPath, data, txid, controlled)
261}
262
263// Add will insert new data at specified location.
Stephane Barbarie4a2564d2018-07-26 11:02:58 -0400264func (p *Proxy) Add(path string, data interface{}, txid string) interface{} {
265 if !strings.HasPrefix(path, "/") {
Stephane Barbarie8c48b5c2018-10-02 09:45:17 -0400266 log.Errorf("invalid path: %s", path)
Stephane Barbarie4a2564d2018-07-26 11:02:58 -0400267 return nil
268 }
269 var fullPath string
Stephane Barbariea188d942018-10-16 16:43:04 -0400270 var effectivePath string
Stephane Barbarie4a2564d2018-07-26 11:02:58 -0400271 if path == "/" {
Stephane Barbariedc5022d2018-11-19 15:21:44 -0500272 fullPath = p.getPath()
273 effectivePath = p.getFullPath()
Stephane Barbarie4a2564d2018-07-26 11:02:58 -0400274 } else {
Stephane Barbariedc5022d2018-11-19 15:21:44 -0500275 fullPath = p.getPath() + path
276 effectivePath = p.getFullPath() + path
Stephane Barbarie4a2564d2018-07-26 11:02:58 -0400277 }
Stephane Barbariea188d942018-10-16 16:43:04 -0400278
279 pathLock, controlled := p.parseForControlledPath(effectivePath)
280
Stephane Barbariedc5022d2018-11-19 15:21:44 -0500281 log.Debugf("Path: %s, Effective: %s, Full: %s, PathLock: %s", path, effectivePath, fullPath, pathLock)
Stephane Barbariea188d942018-10-16 16:43:04 -0400282
Stephane Barbariedc5022d2018-11-19 15:21:44 -0500283 pac := PAC().ReservePath(path, p, pathLock)
284 defer PAC().ReleasePath(pathLock)
285 pac.SetProxy(p)
Stephane Barbariea188d942018-10-16 16:43:04 -0400286
Stephane Barbariedc5022d2018-11-19 15:21:44 -0500287 return pac.Add(fullPath, data, txid, controlled)
Stephane Barbarie4a2564d2018-07-26 11:02:58 -0400288}
289
Stephane Barbariedc5022d2018-11-19 15:21:44 -0500290// Remove will delete an entry at the specified location
Stephane Barbarie4a2564d2018-07-26 11:02:58 -0400291func (p *Proxy) Remove(path string, txid string) interface{} {
292 if !strings.HasPrefix(path, "/") {
Stephane Barbarie8c48b5c2018-10-02 09:45:17 -0400293 log.Errorf("invalid path: %s", path)
Stephane Barbarie4a2564d2018-07-26 11:02:58 -0400294 return nil
295 }
296 var fullPath string
Stephane Barbariea188d942018-10-16 16:43:04 -0400297 var effectivePath string
Stephane Barbarie4a2564d2018-07-26 11:02:58 -0400298 if path == "/" {
Stephane Barbariedc5022d2018-11-19 15:21:44 -0500299 fullPath = p.getPath()
300 effectivePath = p.getFullPath()
Stephane Barbarie4a2564d2018-07-26 11:02:58 -0400301 } else {
Stephane Barbariedc5022d2018-11-19 15:21:44 -0500302 fullPath = p.getPath() + path
303 effectivePath = p.getFullPath() + path
Stephane Barbarie4a2564d2018-07-26 11:02:58 -0400304 }
Stephane Barbariea188d942018-10-16 16:43:04 -0400305
306 pathLock, controlled := p.parseForControlledPath(effectivePath)
307
Stephane Barbariedc5022d2018-11-19 15:21:44 -0500308 log.Debugf("Path: %s, Effective: %s, Full: %s, PathLock: %s", path, effectivePath, fullPath, pathLock)
Stephane Barbariea188d942018-10-16 16:43:04 -0400309
Stephane Barbariedc5022d2018-11-19 15:21:44 -0500310 pac := PAC().ReservePath(effectivePath, p, pathLock)
311 defer PAC().ReleasePath(pathLock)
312 pac.SetProxy(p)
Stephane Barbariea188d942018-10-16 16:43:04 -0400313
Stephane Barbariedc5022d2018-11-19 15:21:44 -0500314 return pac.Remove(fullPath, txid, controlled)
Stephane Barbarie4a2564d2018-07-26 11:02:58 -0400315}
316
Stephane Barbariedc5022d2018-11-19 15:21:44 -0500317// OpenTransaction creates a new transaction branch to isolate operations made to the data model
Stephane Barbarie88fbe7f2018-09-25 12:25:23 -0400318func (p *Proxy) OpenTransaction() *Transaction {
Stephane Barbariedc5022d2018-11-19 15:21:44 -0500319 txid := p.GetRoot().MakeTxBranch()
Stephane Barbarie4a2564d2018-07-26 11:02:58 -0400320 return NewTransaction(p, txid)
321}
322
Stephane Barbariedc5022d2018-11-19 15:21:44 -0500323// commitTransaction will apply and merge modifications made in the transaction branch to the data model
Stephane Barbarie4a2564d2018-07-26 11:02:58 -0400324func (p *Proxy) commitTransaction(txid string) {
Stephane Barbariedc5022d2018-11-19 15:21:44 -0500325 p.GetRoot().FoldTxBranch(txid)
Stephane Barbarie4a2564d2018-07-26 11:02:58 -0400326}
327
Stephane Barbariedc5022d2018-11-19 15:21:44 -0500328// cancelTransaction will terminate a transaction branch along will all changes within it
Stephane Barbarie4a2564d2018-07-26 11:02:58 -0400329func (p *Proxy) cancelTransaction(txid string) {
Stephane Barbariedc5022d2018-11-19 15:21:44 -0500330 p.GetRoot().DeleteTxBranch(txid)
Stephane Barbarie4a2564d2018-07-26 11:02:58 -0400331}
332
Stephane Barbariedc5022d2018-11-19 15:21:44 -0500333// CallbackFunction is a type used to define callback functions
Stephane Barbarie694e2b92018-09-07 12:17:36 -0400334type CallbackFunction func(args ...interface{}) interface{}
Stephane Barbariedc5022d2018-11-19 15:21:44 -0500335
336// CallbackTuple holds the function and arguments details of a callback
Stephane Barbarie694e2b92018-09-07 12:17:36 -0400337type CallbackTuple struct {
338 callback CallbackFunction
339 args []interface{}
Stephane Barbarie4a2564d2018-07-26 11:02:58 -0400340}
341
Stephane Barbariedc5022d2018-11-19 15:21:44 -0500342// Execute will process the a callback with its provided arguments
343func (tuple *CallbackTuple) Execute(contextArgs []interface{}) interface{} {
Stephane Barbarie126101e2018-10-11 16:18:48 -0400344 args := []interface{}{}
Stephane Barbariedc5022d2018-11-19 15:21:44 -0500345
346 for _, ta := range tuple.args {
347 args = append(args, ta)
Stephane Barbarie694e2b92018-09-07 12:17:36 -0400348 }
Stephane Barbariedc5022d2018-11-19 15:21:44 -0500349
350 if contextArgs != nil {
351 for _, ca := range contextArgs {
352 args = append(args, ca)
353 }
354 }
355
Stephane Barbarie126101e2018-10-11 16:18:48 -0400356 return tuple.callback(args...)
Stephane Barbarie4a2564d2018-07-26 11:02:58 -0400357}
358
Stephane Barbariedc5022d2018-11-19 15:21:44 -0500359// RegisterCallback associates a callback to the proxy
Stephane Barbarie694e2b92018-09-07 12:17:36 -0400360func (p *Proxy) RegisterCallback(callbackType CallbackType, callback CallbackFunction, args ...interface{}) {
Stephane Barbariedc5022d2018-11-19 15:21:44 -0500361 if p.getCallbacks(callbackType) == nil {
362 p.setCallbacks(callbackType, make(map[string]*CallbackTuple))
Stephane Barbarie694e2b92018-09-07 12:17:36 -0400363 }
364 funcName := runtime.FuncForPC(reflect.ValueOf(callback).Pointer()).Name()
365 log.Debugf("value of function: %s", funcName)
366 funcHash := fmt.Sprintf("%x", md5.Sum([]byte(funcName)))[:12]
367
Stephane Barbariedc5022d2018-11-19 15:21:44 -0500368 p.setCallback(callbackType, funcHash, &CallbackTuple{callback, args})
Stephane Barbarie694e2b92018-09-07 12:17:36 -0400369}
370
Stephane Barbariedc5022d2018-11-19 15:21:44 -0500371// UnregisterCallback removes references to a callback within a proxy
Stephane Barbarie694e2b92018-09-07 12:17:36 -0400372func (p *Proxy) UnregisterCallback(callbackType CallbackType, callback CallbackFunction, args ...interface{}) {
Stephane Barbariedc5022d2018-11-19 15:21:44 -0500373 if p.getCallbacks(callbackType) == nil {
Stephane Barbarie694e2b92018-09-07 12:17:36 -0400374 log.Errorf("no such callback type - %s", callbackType.String())
375 return
376 }
Stephane Barbariedc5022d2018-11-19 15:21:44 -0500377
Stephane Barbarie694e2b92018-09-07 12:17:36 -0400378 funcName := runtime.FuncForPC(reflect.ValueOf(callback).Pointer()).Name()
Stephane Barbarie694e2b92018-09-07 12:17:36 -0400379 funcHash := fmt.Sprintf("%x", md5.Sum([]byte(funcName)))[:12]
Stephane Barbariedc5022d2018-11-19 15:21:44 -0500380
381 log.Debugf("value of function: %s", funcName)
382
383 if p.getCallback(callbackType, funcHash) == nil {
Stephane Barbarie694e2b92018-09-07 12:17:36 -0400384 log.Errorf("function with hash value: '%s' not registered with callback type: '%s'", funcHash, callbackType)
385 return
386 }
Stephane Barbariedc5022d2018-11-19 15:21:44 -0500387
388 p.DeleteCallback(callbackType, funcHash)
Stephane Barbarie694e2b92018-09-07 12:17:36 -0400389}
390
Stephane Barbariedc5022d2018-11-19 15:21:44 -0500391func (p *Proxy) invoke(callback *CallbackTuple, context []interface{}) (result interface{}, err error) {
Stephane Barbarie694e2b92018-09-07 12:17:36 -0400392 defer func() {
393 if r := recover(); r != nil {
394 errStr := fmt.Sprintf("callback error occurred: %+v", r)
395 err = errors.New(errStr)
396 log.Error(errStr)
397 }
398 }()
399
400 result = callback.Execute(context)
401
402 return result, err
403}
404
Stephane Barbariedc5022d2018-11-19 15:21:44 -0500405// InvokeCallbacks executes all callbacks associated to a specific type
Stephane Barbarie126101e2018-10-11 16:18:48 -0400406func (p *Proxy) InvokeCallbacks(args ...interface{}) (result interface{}) {
Stephane Barbarie694e2b92018-09-07 12:17:36 -0400407 callbackType := args[0].(CallbackType)
Stephane Barbarie126101e2018-10-11 16:18:48 -0400408 proceedOnError := args[1].(bool)
409 context := args[2:]
Stephane Barbarie694e2b92018-09-07 12:17:36 -0400410
411 var err error
412
Stephane Barbariedc5022d2018-11-19 15:21:44 -0500413 if callbacks := p.getCallbacks(callbackType); callbacks != nil {
414 p.Lock()
415 for _, callback := range callbacks {
Stephane Barbarie126101e2018-10-11 16:18:48 -0400416 if result, err = p.invoke(callback, context); err != nil {
Stephane Barbarie694e2b92018-09-07 12:17:36 -0400417 if !proceedOnError {
418 log.Info("An error occurred. Stopping callback invocation")
419 break
420 }
421 log.Info("An error occurred. Invoking next callback")
422 }
423 }
Stephane Barbariedc5022d2018-11-19 15:21:44 -0500424 p.Unlock()
Stephane Barbarie694e2b92018-09-07 12:17:36 -0400425 }
Stephane Barbariedc5022d2018-11-19 15:21:44 -0500426
Stephane Barbariea188d942018-10-16 16:43:04 -0400427 return result
Stephane Barbarie4a2564d2018-07-26 11:02:58 -0400428}