mirror of
https://github.com/denoland/deno.git
synced 2024-11-21 15:04:11 -05:00
fix(ext/kv): add a warning for listenQueue if used with remote KV (#20341)
This commit is contained in:
parent
d6c49353c3
commit
1dc5d42114
4 changed files with 25 additions and 0 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -1301,6 +1301,7 @@ dependencies = [
|
||||||
"rusqlite",
|
"rusqlite",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
|
"termcolor",
|
||||||
"tokio",
|
"tokio",
|
||||||
"url",
|
"url",
|
||||||
"uuid",
|
"uuid",
|
||||||
|
|
|
@ -137,6 +137,7 @@ smallvec = "1.8"
|
||||||
socket2 = { version = "0.5.3", features = ["all"] }
|
socket2 = { version = "0.5.3", features = ["all"] }
|
||||||
tar = "=0.4.40"
|
tar = "=0.4.40"
|
||||||
tempfile = "3.4.0"
|
tempfile = "3.4.0"
|
||||||
|
termcolor = "1.1.3"
|
||||||
thiserror = "1.0.40"
|
thiserror = "1.0.40"
|
||||||
tokio = { version = "1.28.1", features = ["full"] }
|
tokio = { version = "1.28.1", features = ["full"] }
|
||||||
tokio-metrics = { version = "0.3.0", features = ["rt"] }
|
tokio-metrics = { version = "0.3.0", features = ["rt"] }
|
||||||
|
|
|
@ -29,6 +29,7 @@ reqwest.workspace = true
|
||||||
rusqlite.workspace = true
|
rusqlite.workspace = true
|
||||||
serde.workspace = true
|
serde.workspace = true
|
||||||
serde_json.workspace = true
|
serde_json.workspace = true
|
||||||
|
termcolor.workspace = true
|
||||||
tokio.workspace = true
|
tokio.workspace = true
|
||||||
url.workspace = true
|
url.workspace = true
|
||||||
uuid = { workspace = true, features = ["serde"] }
|
uuid = { workspace = true, features = ["serde"] }
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
|
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
|
||||||
|
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
|
use std::fmt;
|
||||||
|
use std::io::Write;
|
||||||
use std::marker::PhantomData;
|
use std::marker::PhantomData;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
@ -29,6 +31,10 @@ use deno_core::OpState;
|
||||||
use prost::Message;
|
use prost::Message;
|
||||||
use rand::Rng;
|
use rand::Rng;
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
|
use termcolor::Ansi;
|
||||||
|
use termcolor::Color;
|
||||||
|
use termcolor::ColorSpec;
|
||||||
|
use termcolor::WriteColor;
|
||||||
use tokio::sync::watch;
|
use tokio::sync::watch;
|
||||||
use url::Url;
|
use url::Url;
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
@ -272,12 +278,28 @@ impl<P: RemoteDbHandlerPermissions> Database for RemoteDb<P> {
|
||||||
&self,
|
&self,
|
||||||
_state: Rc<RefCell<OpState>>,
|
_state: Rc<RefCell<OpState>>,
|
||||||
) -> Result<Self::QMH, AnyError> {
|
) -> Result<Self::QMH, AnyError> {
|
||||||
|
let msg = "Deno.Kv.listenQueue is not supported for remote KV databases";
|
||||||
|
eprintln!("{}", yellow(msg));
|
||||||
deno_core::futures::future::pending().await
|
deno_core::futures::future::pending().await
|
||||||
}
|
}
|
||||||
|
|
||||||
fn close(&self) {}
|
fn close(&self) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn yellow<S: AsRef<str>>(s: S) -> impl fmt::Display {
|
||||||
|
if std::env::var_os("NO_COLOR").is_some() {
|
||||||
|
return String::from(s.as_ref());
|
||||||
|
}
|
||||||
|
let mut style_spec = ColorSpec::new();
|
||||||
|
style_spec.set_fg(Some(Color::Yellow));
|
||||||
|
let mut v = Vec::new();
|
||||||
|
let mut ansi_writer = Ansi::new(&mut v);
|
||||||
|
ansi_writer.set_color(&style_spec).unwrap();
|
||||||
|
ansi_writer.write_all(s.as_ref().as_bytes()).unwrap();
|
||||||
|
ansi_writer.reset().unwrap();
|
||||||
|
String::from_utf8_lossy(&v).into_owned()
|
||||||
|
}
|
||||||
|
|
||||||
fn decode_value(
|
fn decode_value(
|
||||||
value: Vec<u8>,
|
value: Vec<u8>,
|
||||||
encoding: pb::KvValueEncoding,
|
encoding: pb::KvValueEncoding,
|
||||||
|
|
Loading…
Reference in a new issue