Skip to content
This repository was archived by the owner on Oct 18, 2023. It is now read-only.

use LRU cache to store loaded namespaces #689

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
167 changes: 166 additions & 1 deletion Cargo.lock

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

1 change: 1 addition & 0 deletions sqld/Cargo.toml
Original file line number Diff line number Diff line change
@@ -69,6 +69,7 @@ chrono = { version = "0.4.26", features = ["serde"] }
hyper-rustls = { git = "https://github.com/rustls/hyper-rustls.git", rev = "163b3f5" }
rustls-pemfile = "1.0.3"
rustls = "0.21.7"
moka = { version = "0.12.0", features = ["future"] }

[dev-dependencies]
proptest = "1.0.0"
1 change: 0 additions & 1 deletion sqld/src/connection/write_proxy.rs
Original file line number Diff line number Diff line change
@@ -25,7 +25,6 @@ use crate::rpc::proxy::rpc::{DisconnectMessage, ExecuteResults};
use crate::rpc::NAMESPACE_METADATA_KEY;
use crate::stats::Stats;
use crate::{Result, DEFAULT_AUTO_CHECKPOINT};

use super::config::DatabaseConfigStore;
use super::libsql::LibSqlConnection;
use super::program::DescribeResult;
16 changes: 14 additions & 2 deletions sqld/src/error.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use std::sync::Arc;

use axum::response::IntoResponse;
use hyper::StatusCode;
use tonic::metadata::errors::InvalidMetadataValueBytes;
@@ -79,6 +81,9 @@ pub enum Error {
ConflictingRestoreParameters,
#[error("failed to fork database: {0}")]
Fork(#[from] ForkError),
// This is for errors returned by moka
#[error(transparent)]
Ref(#[from] Arc<Self>),
}

trait ResponseError: std::error::Error {
@@ -92,6 +97,12 @@ trait ResponseError: std::error::Error {
impl ResponseError for Error {}

impl IntoResponse for Error {
fn into_response(self) -> axum::response::Response {
(&self).into_response()
}
}

impl IntoResponse for &Error {
fn into_response(self) -> axum::response::Response {
use Error::*;

@@ -129,6 +140,7 @@ impl IntoResponse for Error {
LoadDumpExistingDb => self.format_err(StatusCode::BAD_REQUEST),
ConflictingRestoreParameters => self.format_err(StatusCode::BAD_REQUEST),
Fork(e) => e.into_response(),
Ref(this) => this.as_ref().into_response(),
}
}
}
@@ -169,7 +181,7 @@ pub enum LoadDumpError {

impl ResponseError for LoadDumpError {}

impl IntoResponse for LoadDumpError {
impl IntoResponse for &LoadDumpError {
fn into_response(self) -> axum::response::Response {
use LoadDumpError::*;

@@ -187,7 +199,7 @@ impl IntoResponse for LoadDumpError {

impl ResponseError for ForkError {}

impl IntoResponse for ForkError {
impl IntoResponse for &ForkError {
fn into_response(self) -> axum::response::Response {
match self {
ForkError::Internal(_)
Loading