Skip to content

Commit

Permalink
Merge pull request #23 from G8XSU/sqlite-paginated-impl
Browse files Browse the repository at this point in the history
Add Sqlite based PaginatedKVStore impl.
  • Loading branch information
G8XSU authored Dec 4, 2024
2 parents ecfe4cc + 7eab8bf commit 31026d6
Show file tree
Hide file tree
Showing 6 changed files with 551 additions and 3 deletions.
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions ldk-server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,7 @@ prost = { version = "0.11.6", default-features = false, features = ["std"] }
ldk-server-protos = { path = "../ldk-server-protos" }
bytes = "1.4.0"
hex = { package = "hex-conservative", version = "0.2.1", default-features = false }
rusqlite = { version = "0.28.0", features = ["bundled"] }

[dev-dependencies]
rand = "0.8.5"
2 changes: 2 additions & 0 deletions ldk-server/src/io/mod.rs
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
pub(crate) mod paginated_kv_store;
pub(crate) mod sqlite_store;
pub(crate) mod utils;
7 changes: 4 additions & 3 deletions ldk-server/src/io/paginated_kv_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ pub trait PaginatedKVStore {
/// `primary_namespace`, ordered in descending order of `time`.
///
/// The `list` method returns the latest records first, based on the `time` associated with each key.
/// Pagination is controlled by the `next_page_token`, which is an `Option<String>`
/// Pagination is controlled by the `next_page_token`, which is an `Option<(String, i64)>`
/// used to determine the starting point for the next page of results. If `next_page_token` is `None`,
/// the listing starts from the most recent entry. The `next_page_token` in the returned
/// [`ListResponse`] can be used to fetch the next page of results.
Expand All @@ -85,7 +85,8 @@ pub trait PaginatedKVStore {
///
/// [`ListResponse`]: struct.ListResponse.html
fn list(
&self, primary_namespace: &str, secondary_namespace: &str, next_page_token: Option<String>,
&self, primary_namespace: &str, secondary_namespace: &str,
next_page_token: Option<(String, i64)>,
) -> Result<ListResponse, io::Error>;
}

Expand All @@ -98,5 +99,5 @@ pub struct ListResponse {
pub keys: Vec<String>,

/// A token that can be used to retrieve the next set of keys.
pub next_page_token: Option<String>,
pub next_page_token: Option<(String, i64)>,
}
Loading

0 comments on commit 31026d6

Please sign in to comment.