Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(unstable): kv.watch() #21147

Merged
merged 9 commits into from
Dec 5, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
bump denokv
  • Loading branch information
losfair committed Nov 15, 2023
commit 8dc1b40213756b3eb85afe7bf34312345f3f95b0
7 changes: 4 additions & 3 deletions Cargo.lock

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

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ test_util = { path = "./test_util" }
deno_lockfile = "0.17.2"
deno_media_type = { version = "0.1.1", features = ["module_specifier"] }

denokv_proto = { git = "https://github.com/denoland/denokv", rev = "9189d8c" }
denokv_sqlite = { git = "https://github.com/denoland/denokv", rev = "9189d8c" }
denokv_remote = { git = "https://github.com/denoland/denokv", rev = "9189d8c" }
denokv_proto = { git = "https://github.com/denoland/denokv", rev = "b27fdc1a1a148ab9590c5eff4d2430aa6ee075b4" }
denokv_sqlite = { git = "https://github.com/denoland/denokv", rev = "b27fdc1a1a148ab9590c5eff4d2430aa6ee075b4" }
denokv_remote = { git = "https://github.com/denoland/denokv", rev = "b27fdc1a1a148ab9590c5eff4d2430aa6ee075b4" }

# exts
deno_broadcast_channel = { version = "0.117.0", path = "./ext/broadcast_channel" }
Expand Down
9 changes: 5 additions & 4 deletions ext/kv/sqlite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ use deno_core::error::AnyError;
use deno_core::unsync::spawn_blocking;
use deno_core::OpState;
use deno_node::PathClean;
pub use denokv_sqlite::SqliteBackendError;
use denokv_sqlite::SqliteNotifier;
pub use denokv_sqlite::TypeError;
use rand::RngCore;
use rand::SeedableRng;
use rusqlite::OpenFlags;
Expand Down Expand Up @@ -94,22 +94,23 @@ impl<P: SqliteDbHandlerPermissions> DatabaseHandler for SqliteDbHandler<P> {
(Some(path), _) => {
let flags =
OpenFlags::default().difference(OpenFlags::SQLITE_OPEN_URI);
let resolved_path = canonicalize_path(&PathBuf::from(path))?;
let resolved_path = canonicalize_path(&PathBuf::from(path))
.map_err(anyhow::Error::from)?;
(
rusqlite::Connection::open_with_flags(path, flags)?,
Some(resolved_path),
)
}
(None, Some(path)) => {
std::fs::create_dir_all(path)?;
std::fs::create_dir_all(path).map_err(anyhow::Error::from)?;
let path = path.join("kv.sqlite3");
(rusqlite::Connection::open(path.clone())?, Some(path))
}
};

conn.pragma_update(None, "journal_mode", "wal")?;

Ok::<_, AnyError>((conn, notifier_key))
Ok::<_, SqliteBackendError>((conn, notifier_key))
})
})
.await
Expand Down
2 changes: 1 addition & 1 deletion runtime/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ pub fn get_error_class_name(e: &AnyError) -> Option<&'static str> {
.map(get_url_parse_error_class)
})
.or_else(|| {
e.downcast_ref::<deno_kv::sqlite::TypeError>()
e.downcast_ref::<deno_kv::sqlite::SqliteBackendError>()
.map(|_| "TypeError")
})
.or_else(|| {
Expand Down