| 95 | } |
| 96 | |
| 97 | func ContextUpdatesCommitTx(ctx context.Context) { |
| 98 | updatesVal := ctx.Value(waveObjUpdateKey) |
| 99 | if updatesVal == nil { |
| 100 | return |
| 101 | } |
| 102 | updates := updatesVal.(*contextUpdatesType) |
| 103 | if len(updates.UpdatesStack) <= 1 { |
| 104 | panic(fmt.Errorf("no updates transaction to commit")) |
| 105 | } |
| 106 | // merge the last two updates |
| 107 | curUpdateMap := updates.UpdatesStack[len(updates.UpdatesStack)-1] |
| 108 | prevUpdateMap := updates.UpdatesStack[len(updates.UpdatesStack)-2] |
| 109 | for k, v := range curUpdateMap { |
| 110 | prevUpdateMap[k] = v |
| 111 | } |
| 112 | updates.UpdatesStack = updates.UpdatesStack[:len(updates.UpdatesStack)-1] |
| 113 | } |
| 114 | |
| 115 | func ContextUpdatesRollbackTx(ctx context.Context) { |
| 116 | updatesVal := ctx.Value(waveObjUpdateKey) |