Skip to content

Commit 5fb2d6c

Browse files
authored
Merge pull request #10 from G8XSU/non-conditional-client
Update api/docs for non-conditional writes
2 parents 3f54794 + fc5a401 commit 5fb2d6c

File tree

2 files changed

+40
-18
lines changed

2 files changed

+40
-18
lines changed

build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ fn main() {
1414
#[cfg(feature = "genproto")]
1515
fn generate_protos() {
1616
download_file(
17-
"https://raw.githubusercontent.com/lightningdevkit/vss-server/ac646dd419bc70db2b79772b1bfa1b2d9a4b8b53/app/src/main/proto/vss.proto",
17+
"https://raw.githubusercontent.com/lightningdevkit/vss-server/e1a88afd61f56d7e8e90a32036ca12389e36fe44/app/src/main/proto/vss.proto",
1818
"src/proto/vss.proto",
1919
).unwrap();
2020

src/types.rs

Lines changed: 39 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -71,18 +71,26 @@ pub struct PutObjectRequest {
7171
/// a database-transaction in an all-or-nothing fashion.
7272
/// All Items in a single `PutObjectRequest` must have distinct keys.
7373
///
74-
/// Clients are expected to store a `version` against every `key`.
75-
/// The write will succeed if the current DB version against the `key` is the same as in the request.
76-
/// When initiating a `PutObjectRequest`, the request should contain their client-side version for
77-
/// that key-value.
78-
///
79-
/// For the first write of any key, the `version` should be '0'. If the write succeeds, the client
80-
/// must increment their corresponding key versions (client-side) by 1.
81-
/// The server increments key versions (server-side) for every successful write, hence this
82-
/// client-side increment is required to ensure matching versions. These updated key versions should
83-
/// be used in subsequent `PutObjectRequest`s for the keys.
74+
/// Key-level versioning (Conditional Write):
75+
/// Clients are expected to store a `version` against every `key`.
76+
/// The write will succeed if the current DB version against the `key` is the same as in the request.
77+
/// When initiating a `PutObjectRequest`, the request should contain their client-side `version`
78+
/// for that key-value.
8479
///
85-
/// Requests with a conflicting version will fail with `CONFLICT_EXCEPTION` as ErrorCode.
80+
/// For the first write of any `key`, the `version` should be '0'. If the write succeeds, the client
81+
/// must increment their corresponding key versions (client-side) by 1.
82+
/// The server increments key versions (server-side) for every successful write, hence this
83+
/// client-side increment is required to ensure matching versions. These updated key versions should
84+
/// be used in subsequent `PutObjectRequest`s for the keys.
85+
///
86+
/// Requests with a conflicting/mismatched version will fail with `CONFLICT_EXCEPTION` as ErrorCode
87+
/// for conditional writes.
88+
///
89+
/// Skipping key-level versioning (Non-conditional Write):
90+
/// If you wish to skip key-level version checks, set the `version` against the `key` to '-1'.
91+
/// This will perform a non-conditional write query, after which the `version` against the `key`
92+
/// is reset to '1'. Hence, the next `PutObjectRequest` for the `key` can be either
93+
/// a non-conditional write or a conditional write with `version` set to `1`.
8694
///
8795
/// Considerations for transactions:
8896
/// Transaction writes of multiple items have a performance overhead, hence it is recommended to use
@@ -99,13 +107,20 @@ pub struct PutObjectRequest {
99107
/// Items to be deleted as a result of this `PutObjectRequest`.
100108
///
101109
/// Each item in the `delete_items` field consists of a `key` and its corresponding `version`.
102-
/// The `version` is used to perform a version check before deleting the item.
103-
/// The delete will only succeed if the current database version against the `key` is the same as the `version`
104-
/// specified in the request.
110+
///
111+
/// Key-Level Versioning (Conditional Delete):
112+
/// The `version` is used to perform a version check before deleting the item.
113+
/// The delete will only succeed if the current database version against the `key` is the same as
114+
/// the `version` specified in the request.
115+
///
116+
/// Skipping key-level versioning (Non-conditional Delete):
117+
/// If you wish to skip key-level version checks, set the `version` against the `key` to '-1'.
118+
/// This will perform a non-conditional delete query.
105119
///
106120
/// Fails with `CONFLICT_EXCEPTION` as the ErrorCode if:
107121
/// * The requested item does not exist.
108-
/// * The requested item does exist but there is a version-number mismatch with the one in the database.
122+
/// * The requested item does exist but there is a version-number mismatch (in conditional delete)
123+
/// with the one in the database.
109124
///
110125
/// Multiple items in the `delete_items` field, along with the `transaction_items`, are written in a
111126
/// database transaction in an all-or-nothing fashion.
@@ -133,8 +148,15 @@ pub struct DeleteObjectRequest {
133148
/// Item to be deleted as a result of this `DeleteObjectRequest`.
134149
///
135150
/// An item consists of a `key` and its corresponding `version`.
136-
/// The item is only deleted if the current database version against the `key` is the same as the `version`
137-
/// specified in the request.
151+
///
152+
/// Key-level Versioning (Conditional Delete):
153+
/// The item is only deleted if the current database version against the `key` is the same as
154+
/// the `version` specified in the request.
155+
///
156+
/// Skipping key-level versioning (Non-conditional Delete):
157+
/// If you wish to skip key-level version checks, set the `version` against the `key` to '-1'.
158+
/// This will perform a non-conditional delete query.
159+
///
138160
/// This operation is idempotent, that is, multiple delete calls for the same item will not fail.
139161
///
140162
/// If the requested item does not exist, this operation will not fail.

0 commit comments

Comments
 (0)