Txn is the interface that wraps mini-transactions. Txn(context.TODO()).If( Compare(Value(k1), ">", v1), Compare(Version(k1), "=", 2) ).Then( OpPut(k2,v2), OpPut(k3,v3) ).Else( OpPut(k4,v4), OpPut(k5,v5) ).Commit()
| 34 | // OpPut(k4,v4), OpPut(k5,v5) |
| 35 | // ).Commit() |
| 36 | type Txn interface { |
| 37 | // If takes a list of comparison. If all comparisons passed in succeed, |
| 38 | // the operations passed into Then() will be executed. Or the operations |
| 39 | // passed into Else() will be executed. |
| 40 | If(cs ...Cmp) Txn |
| 41 | |
| 42 | // Then takes a list of operations. The Ops list will be executed, if the |
| 43 | // comparisons passed in If() succeed. |
| 44 | Then(ops ...Op) Txn |
| 45 | |
| 46 | // Else takes a list of operations. The Ops list will be executed, if the |
| 47 | // comparisons passed in If() fail. |
| 48 | Else(ops ...Op) Txn |
| 49 | |
| 50 | // Commit tries to commit the transaction. |
| 51 | Commit() (*TxnResponse, error) |
| 52 | } |
| 53 | |
| 54 | type txn struct { |
| 55 | kv *kv |
no outgoing calls
no test coverage detected