MCPcopy
hub / github.com/etcd-io/etcd / Txn

Interface Txn

client/v3/txn.go:36–52  ·  view source on GitHub ↗

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()

Source from the content-addressed store, hash-verified

34// OpPut(k4,v4), OpPut(k5,v5)
35// ).Commit()
36type 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
54type txn struct {
55 kv *kv

Callers 32

ExampleAuthFunction · 0.65
TestTxnPanicsFunction · 0.65
ExampleKV_txnFunction · 0.65
IfMethod · 0.65
serverTxnMethod · 0.65
DoMethod · 0.65
rescindMethod · 0.65
tryModifyOpMethod · 0.65
mixedTxnFuncFunction · 0.65
txnPutFuncFunction · 0.65
ExampleAuthFunction · 0.65
TestTxnPanicsFunction · 0.65

Implementers 5

txnclient/v3/txn.go
txnLeasingclient/v3/leasing/txn.go
txnOrderingclient/v3/ordering/kv.go
txnPrefixclient/v3/namespace/kv.go
wrappedTxntests/robustness/client/client.go

Calls

no outgoing calls

Tested by

no test coverage detected