/* Ċ Ġ* ĠCopyright ĠÂ© Ġ 2 0 2 1 ĠPaul ĠAmb rose Ġ( p amb rose @ mac . com ) Ċ Ġ* Ċ Ġ* ĠLicensed Ġunder Ġthe ĠApache ĠLicense , ĠVersion Ġ 2 . 0 Ġ( the Ġ" License "); Ċ Ġ* Ġyou Ġmay Ġnot Ġuse Ġthis Ġfile Ġexcept Ġin Ġcompliance Ġwith Ġthe ĠLicense . Ċ Ġ* ĠYou Ġmay Ġobtain Ġa Ġcopy Ġof Ġthe ĠLicense Ġat Ċ Ġ* Ċ Ġ* ĠĠĠĠĠĠ Ġhttp :// www . apache . org / licenses / LICENSE - 2 . 0 Ċ Ġ* Ċ Ġ* ĠUnless Ġrequired Ġby Ġapplicable Ġlaw Ġor Ġagreed Ġto Ġin Ġwriting , Ġsoftware Ċ Ġ* Ġdistributed Ġunder Ġthe ĠLicense Ġis Ġdistributed Ġon Ġan Ġ" AS ĠIS " ĠBASIS , Ċ Ġ* ĠWITHOUT ĠWARRANTIES ĠOR ĠCONDITIONS ĠOF ĠANY ĠKIND , Ġeither Ġexpress Ġor Ġimplied . Ċ Ġ* ĠSee Ġthe ĠLicense Ġfor Ġthe Ġspecific Ġlanguage Ġgoverning Ġpermissions Ġand Ċ Ġ* Ġlimitations Ġunder Ġthe ĠLicense . Ċ Ġ*/ Ċ Ċ @ file : Jvm Name (" Txn Utils ") Ċ @ file : Suppress (" Un document ed Public Class ", Ġ" Un document ed Public Function ") Ċ Ċ package Ġio . etcd . recipes . common Ċ Ċ import Ġio . etcd . jet cd . Byte Sequence Ċ import Ġio . etcd . jet cd . Client Ċ import Ġio . etcd . jet cd . Txn Ċ import Ġio . etcd . jet cd . kv . Txn Response Ċ import Ġio . etcd . jet cd . op . Cmp Ċ import Ġio . etcd . jet cd . op . Cmp Target Ċ import Ġio . etcd . jet cd . op . Op Ċ import Ġio . etcd . jet cd . options . Delete Option Ċ import Ġio . etcd . jet cd . options . Put Option Ċ Ċ fun ĠClient . transaction ( rec ie ver : ĠTx n . () Ġ-> ĠTx n ): ĠTx n Response Ġ= ĊĠ Ġkv Client . txn (). run Ġ{ ĊĠĠĠ Ġrec ie ver () ĊĠĠĠ Ġcommit () ĊĠ Ġ}. get () Ċ Ċ fun Ġ< T > ĠequalTo ( bytes : ĠByte Sequence , Ġtarget : ĠC mp Target < T >): ĠC mp Ġ= ĠC mp ( bytes , ĠC mp . Op . EQUAL , Ġtarget ) Ċ fun Ġ< T > Ġless Than ( bytes : ĠByte Sequence , Ġtarget : ĠC mp Target < T >): ĠC mp Ġ= ĠC mp ( bytes , ĠC mp . Op . LESS , Ġtarget ) Ċ fun Ġ< T > Ġgreater Than ( bytes : ĠByte Sequence , Ġtarget : ĠC mp Target < T >): ĠC mp Ġ= ĠC mp ( bytes , ĠC mp . Op . GRE ATER , Ġtarget ) Ċ Ċ fun Ġ< T > ĠequalTo ( value : ĠString , Ġtarget : ĠC mp Target < T >): ĠC mp Ġ= ĠequalTo ( value . as Byte Sequence , Ġtarget ) Ċ fun Ġ< T > Ġless Than ( value : ĠString , Ġtarget : ĠC mp Target < T >): ĠC mp Ġ= Ġless Than ( value . as Byte Sequence , Ġtarget ) Ċ fun Ġ< T > Ġgreater Than ( value : ĠString , Ġtarget : ĠC mp Target < T >): ĠC mp Ġ= Ġgreater Than ( value . as Byte Sequence , Ġtarget ) Ċ Ċ fun Ġ< T > ĠequalTo ( value : ĠInt , Ġtarget : ĠC mp Target < T >): ĠC mp Ġ= ĠequalTo ( value . as Byte Sequence , Ġtarget ) Ċ fun Ġ< T > Ġless Than ( value : ĠInt , Ġtarget : ĠC mp Target < T >): ĠC mp Ġ= Ġless Than ( value . as Byte Sequence , Ġtarget ) Ċ fun Ġ< T > Ġgreater Than ( value : ĠInt , Ġtarget : ĠC mp Target < T >): ĠC mp Ġ= Ġgreater Than ( value . as Byte Sequence , Ġtarget ) Ċ Ċ fun Ġ< T > ĠequalTo ( value : ĠLong , Ġtarget : ĠC mp Target < T >): ĠC mp Ġ= ĠequalTo ( value . as Byte Sequence , Ġtarget ) Ċ fun Ġ< T > Ġless Than ( value : ĠLong , Ġtarget : ĠC mp Target < T >): ĠC mp Ġ= Ġless Than ( value . as Byte Sequence , Ġtarget ) Ċ fun Ġ< T > Ġgreater Than ( value : ĠLong , Ġtarget : ĠC mp Target < T >): ĠC mp Ġ= Ġgreater Than ( value . as Byte Sequence , Ġtarget ) Ċ Ċ val ĠString . does NotExist : ĠC mp Ġget () Ġ= ĠequalTo ( this , ĠC mp Target . version ( 0 )) Ċ val ĠString . does Exist : ĠC mp Ġget () Ġ= Ġgreater Than ( this , ĠC mp Target . version ( 0 )) Ċ Ċ @ Jvm Over loads Ċ fun Ġdelete Op ( key : ĠByte Sequence , Ġoption : ĠDelete Option Ġ= ĠDelete Option . DEFAULT ): ĠOp . Delete Op Ġ= ĠOp . delete ( key , Ġoption ) Ċ Ċ @ Jvm Over loads Ċ fun Ġdelete Op ( key : ĠString , Ġoption : ĠDelete Option Ġ= ĠDelete Option . DEFAULT ): ĠOp . Delete Op Ġ= ĊĠ Ġdelete Op ( key . as Byte Sequence , Ġoption ) Ċ Ċ fun ĠString . set To ( value : ĠByte Sequence , Ġput Option : ĠPut Option ): ĠOp . Put Op Ġ= ĊĠ ĠOp . put ( as Byte Sequence , Ġvalue , Ġput Option ) Ċ Ċ fun ĠString . set To ( key val : ĠString , Ġput Option : ĠPut Option ): ĠOp . Put Op Ġ= ĊĠ ĠOp . put ( as Byte Sequence , Ġkey val . as Byte Sequence , Ġput Option ) Ċ Ċ fun ĠString . set To ( key val : ĠInt , Ġput Option : ĠPut Option ): ĠOp . Put Op Ġ= ĊĠ ĠOp . put ( as Byte Sequence , Ġkey val . as Byte Sequence , Ġput Option ) Ċ Ċ fun ĠString . set To ( key val : ĠLong , Ġput Option : ĠPut Option ): ĠOp . Put Op Ġ= ĊĠ ĠOp . put ( as Byte Sequence , Ġkey val . as Byte Sequence , Ġput Option ) Ċ Ċ infix Ġfun ĠString . set To ( value : ĠByte Sequence ): ĠOp . Put Op Ġ= Ġset To ( value , ĠPut Option . DEFAULT ) Ċ infix Ġfun ĠString . set To ( key val : ĠString ): ĠOp . Put Op Ġ= Ġset To ( key val , ĠPut Option . DEFAULT ) Ċ infix Ġfun ĠString . set To ( key val : ĠInt ): ĠOp . Put Op Ġ= Ġset To ( key val , ĠPut Option . DEFAULT ) Ċ infix Ġfun ĠString . set To ( key val : ĠLong ): ĠOp . Put Op Ġ= Ġset To ( key val , ĠPut Option . DEFAULT )