@@ -28,45 +28,70 @@ use tokio::task::JoinSet;
2828use tonic:: codegen:: tokio_stream:: StreamExt ;
2929use tonic:: { async_trait, Request } ;
3030
31+ /// Options for put operations.
3132pub enum PutOption {
32- /// Only succeed if the record does not already exist (equivalent to ExpectVersionId(-1))
33+ /// Only succeed if the record does not already exist (equivalent to ExpectVersionId(-1)).
3334 ExpectedRecordNotExists ( ) ,
34- /// Only succeed if the current version matches
35+ /// Only succeed if the current version matches the specified version ID (CAS operation).
3536 ExpectVersionId ( i64 ) ,
37+ /// Override partition routing. Records with the same partition key are co-located on the same shard.
3638 PartitionKey ( String ) ,
39+ /// Server-assigned atomic sequential keys. The key will get added suffixes based on
40+ /// adding the delta to the current highest key with the same prefix.
3741 SequenceKeyDelta ( Vec < u64 > ) ,
42+ /// Associate secondary indexes with the record for alternative query paths.
3843 SecondaryIndexes ( Vec < SecondaryIndex > ) ,
44+ /// Create an ephemeral record that is automatically deleted when the client's session
45+ /// is closed or expires.
3946 Ephemeral ( ) ,
4047}
4148
49+ /// The result of a put operation.
4250#[ derive( Clone , Debug , PartialEq ) ]
4351pub struct PutResult {
52+ /// The key of the stored record. May differ from the requested key when using sequence deltas.
4453 pub key : String ,
54+ /// The version metadata of the stored record.
4555 pub version : Version ,
4656}
4757
58+ /// Options for delete operations.
4859pub enum DeleteOption {
60+ /// Override partition routing.
4961 PartitionKey ( String ) ,
62+ /// Only delete if the current version matches (conditional delete).
5063 ExpectVersionId ( i64 ) ,
64+ /// Only delete if the record does not exist (no-op check).
5165 RecordDoesNotExist ( ) ,
5266}
5367
68+ /// Options for delete range operations.
5469pub enum DeleteRangeOption {
70+ /// Override partition routing.
5571 PartitionKey ( String ) ,
5672}
5773
74+ /// Options for get operations.
5875pub enum GetOption {
76+ /// Key comparison type: Equal (default), Floor, Ceiling, Lower, Higher.
5977 ComparisonType ( KeyComparisonType ) ,
78+ /// Override partition routing.
6079 PartitionKey ( String ) ,
61- /// Include the value in the response (default: true)
80+ /// Whether to include the value in the response (default: true).
81+ /// Set to false for metadata-only queries.
6282 IncludeValue ( bool ) ,
83+ /// Query a secondary index instead of the primary key space.
6384 UseIndex ( String ) ,
6485}
6586
87+ /// The result of a get operation.
6688#[ derive( Clone , Debug , PartialEq ) ]
6789pub struct GetResult {
90+ /// The key of the record. May differ from the requested key when using comparison queries.
6891 pub key : String ,
92+ /// The value of the record. None if the value was not requested or the record has no value.
6993 pub value : Option < Vec < u8 > > ,
94+ /// The version metadata of the record.
7095 pub version : Version ,
7196}
7297impl Eq for GetResult { }
@@ -83,32 +108,47 @@ impl Ord for GetResult {
83108 }
84109}
85110
111+ /// Options for list operations.
86112pub enum ListOption {
113+ /// Override partition routing.
87114 PartitionKey ( String ) ,
115+ /// Query a secondary index instead of the primary key space.
88116 UseIndex ( String ) ,
89117}
90118
119+ /// The result of a list operation.
91120#[ derive( Clone , Debug , PartialEq ) ]
92121pub struct ListResult {
122+ /// The keys found within the specified range.
93123 pub keys : Vec < String > ,
94124}
95125
126+ /// Options for range scan operations.
96127pub enum RangeScanOption {
128+ /// Override partition routing.
97129 PartitionKey ( String ) ,
130+ /// Query a secondary index instead of the primary key space.
98131 UseIndex ( String ) ,
99132}
100133
134+ /// The result of a range scan operation.
101135#[ derive( Clone , Debug , PartialEq ) ]
102136pub struct RangeScanResult {
137+ /// The records found within the specified range, including keys, values, and versions.
103138 pub records : Vec < GetResult > ,
104139}
105140
141+ /// Options for notification subscriptions.
106142pub enum GetNotificationOption {
143+ /// Buffer size for the notification channel (default: 100).
107144 BufferSize ( usize ) ,
108145}
109146
147+ /// Options for sequence update subscriptions.
110148pub enum GetSequenceUpdatesOption {
149+ /// Required: the partition key for the sequence. Must be specified.
111150 PartitionKey ( String ) ,
151+ /// Buffer size for the sequence updates channel (default: 100).
112152 BufferSize ( usize ) ,
113153}
114154
@@ -135,12 +175,18 @@ pub struct KeyRangeDeleted {
135175 pub key_range_last : Option < String > ,
136176}
137177
178+ /// A change notification received from Oxia.
138179#[ derive( Clone , Debug , PartialEq ) ]
139180pub enum Notification {
181+ /// A new key was created.
140182 KeyCreated ( KeyCreated ) ,
183+ /// A key was deleted.
141184 KeyDeleted ( KeyDeleted ) ,
185+ /// An existing key was modified.
142186 KeyModified ( KeyModified ) ,
187+ /// A range of keys was deleted.
143188 KeyRangeDeleted ( KeyRangeDeleted ) ,
189+ /// An unknown notification type was received.
144190 Unknown ( ) ,
145191}
146192
0 commit comments