add a crate k2v client #303

Merged
lx merged 5 commits from trinity-1686a/garage:k2v-client into main 2022-05-18 20:24:15 +00:00
3 changed files with 9 additions and 10 deletions
Showing only changes of commit d0e3434104 - Show all commits

View file

@ -79,6 +79,8 @@ function refresh_toolchain {
pkgs.rustfmt
pkgs.perl
pkgs.protobuf
pkgs.pkg-config
pkgs.openssl
cargo2nix.packages.x86_64-linux.cargo2nix
] else [])
++

View file

@ -1,7 +1,7 @@
[package]
name = "k2v-client"
version = "0.1.0"
edition = "2021"
edition = "2018"
[dependencies]
base64 = "0.13.0"

View file

@ -200,9 +200,9 @@ impl K2vClient {
// TODO poke team, draft doc outdated fot the return type of this endpoint
lx marked this conversation as resolved
Review

thx

thx
/// Perform a ReadIndex request, listing partition key which have at least one associated
/// sort key, and which matches the filter.
pub async fn read_index<'a>(
pub async fn read_index(
lx marked this conversation as resolved Outdated

The documentation says the response is

{
  prefix: null,
  start: null,
  end: null,
  limit: null,
  reverse: false,
  partitionKeys: [
    { pk: "keys", n: 3043 },
    { pk: "mailbox:INBOX", n: 42 },
    { pk: "mailbox:Junk", n: 2991 },
    { pk: "mailbox:Trash", n: 10 },
    { pk: "mailboxes", n: 3 },
  ],
  more: false,
  nextStart: null,
}

but actually partitionKeys values are {pk: "keys", entries: 1, conflicts: 1, values: 1, bytes: 1}

The documentation says the response is ```json { prefix: null, start: null, end: null, limit: null, reverse: false, partitionKeys: [ { pk: "keys", n: 3043 }, { pk: "mailbox:INBOX", n: 42 }, { pk: "mailbox:Junk", n: 2991 }, { pk: "mailbox:Trash", n: 10 }, { pk: "mailboxes", n: 3 }, ], more: false, nextStart: null, } ``` but actually partitionKeys values are `{pk: "keys", entries: 1, conflicts: 1, values: 1, bytes: 1}`
&self,
filter: Filter<'a>,
filter: Filter<'_>,
) -> Result<PaginatedRange<PartitionInfo>, Error> {
let mut req =
SignedRequest::new("GET", SERVICE, &self.region, &format!("/{}", self.bucket));
@ -227,7 +227,7 @@ impl K2vClient {
/// Perform an InsertBatch request, inserting multiple values at once. Note: this operation is
/// *not* atomic: it is possible for some sub-operations to fails and others to success. In
/// that case, failure is reported.
pub async fn insert_batch<'a>(&self, operations: &[BatchInsertOp<'a>]) -> Result<(), Error> {
pub async fn insert_batch(&self, operations: &[BatchInsertOp<'_>]) -> Result<(), Error> {
let mut req =
SignedRequest::new("POST", SERVICE, &self.region, &format!("/{}", self.bucket));
@ -238,9 +238,9 @@ impl K2vClient {
}
/// Perform a ReadBatch request, reading multiple values or range of values at once.
pub async fn read_batch<'a>(
pub async fn read_batch(
&self,
operations: &[BatchReadOp<'a>],
operations: &[BatchReadOp<'_>],
) -> Result<Vec<PaginatedRange<CausalValue>>, Error> {
let mut req =
SignedRequest::new("POST", SERVICE, &self.region, &format!("/{}", self.bucket));
@ -275,10 +275,7 @@ impl K2vClient {
/// Perform a DeleteBatch request, deleting mutiple values or range of values at once, without
/// providing causality information.
pub async fn delete_batch<'a>(
&self,
operations: &[BatchDeleteOp<'a>],
) -> Result<Vec<u64>, Error> {
pub async fn delete_batch(&self, operations: &[BatchDeleteOp<'_>]) -> Result<Vec<u64>, Error> {
let mut req =
SignedRequest::new("POST", SERVICE, &self.region, &format!("/{}", self.bucket));
req.add_param("delete", "");