etcdv3 / etcd-client

An etcd v3 API client
Apache License 2.0
210 stars 51 forks source link

how to implement CAS operation? #44

Closed lnparker closed 2 years ago

lnparker commented 2 years ago

if i want to implement an id generator with etcd, it seems that i need below operation in one transaction : let t = etcd_client::new_txn(); let old_id = t.get("id_key"); let new_id = old_id + 1; t.set("id_key", new_id); t.commit(); or using CAS(compare and swap operation). but i can not find proper method to impement in this project. is there any suggestions? thanks