Add live query feature flag (#3396)
This commit is contained in:
parent
f1ae36f332
commit
c5aca609cd
4 changed files with 71 additions and 2 deletions
68
lib/src/fflags.rs
Normal file
68
lib/src/fflags.rs
Normal file
|
@ -0,0 +1,68 @@
|
|||
#[allow(dead_code)]
|
||||
pub(crate) static FFLAGS: FFlags = FFlags {
|
||||
change_feed_live_queries: FFlagEnabledStatus {
|
||||
enabled_release: false,
|
||||
enabled_debug: false,
|
||||
enabled_test: false,
|
||||
env_override: "SURREALDB_CHANGE_FEED_LIVE_QUERIES",
|
||||
owner: "Hugh Kaznowski",
|
||||
description: "Disables live queries as a separate feature and moves to using change feeds as the underlying mechanism",
|
||||
date_enabled_test: None,
|
||||
date_enabled_debug: None,
|
||||
date_enabled_release: None,
|
||||
release_version: None,
|
||||
}
|
||||
};
|
||||
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
|
||||
#[non_exhaustive]
|
||||
#[allow(dead_code)]
|
||||
pub(crate) struct FFlags {
|
||||
pub(crate) change_feed_live_queries: FFlagEnabledStatus,
|
||||
}
|
||||
|
||||
/// This struct is not used in the implementation;
|
||||
/// All the fields are here as information for people investigating the feature flag.
|
||||
#[allow(dead_code)]
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
|
||||
pub(crate) struct FFlagEnabledStatus {
|
||||
pub(crate) enabled_release: bool,
|
||||
pub(crate) enabled_debug: bool,
|
||||
pub(crate) enabled_test: bool,
|
||||
pub(crate) owner: &'static str,
|
||||
pub(crate) description: &'static str,
|
||||
pub(crate) env_override: &'static str,
|
||||
pub(crate) date_enabled_test: Option<&'static str>,
|
||||
pub(crate) date_enabled_debug: Option<&'static str>,
|
||||
pub(crate) date_enabled_release: Option<&'static str>,
|
||||
pub(crate) release_version: Option<&'static str>,
|
||||
}
|
||||
|
||||
impl FFlagEnabledStatus {
|
||||
#[allow(dead_code)]
|
||||
pub(crate) fn enabled(&self) -> bool {
|
||||
let mut enabled = false;
|
||||
if let Ok(env_var) = std::env::var(self.env_override) {
|
||||
if env_var.trim() == "true" {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
// Test check
|
||||
#[cfg(test)]
|
||||
{
|
||||
enabled = enabled || self.enabled_test;
|
||||
}
|
||||
// Debug build check
|
||||
#[cfg(debug_assertions)]
|
||||
{
|
||||
enabled = enabled || self.enabled_debug;
|
||||
}
|
||||
// Release build check
|
||||
#[cfg(not(debug_assertions))]
|
||||
{
|
||||
enabled = enabled || self.enabled_release;
|
||||
}
|
||||
enabled
|
||||
}
|
||||
}
|
|
@ -123,6 +123,7 @@ pub mod dbs;
|
|||
pub mod env;
|
||||
#[doc(hidden)]
|
||||
pub mod err;
|
||||
pub(crate) mod fflags;
|
||||
#[doc(hidden)]
|
||||
pub mod iam;
|
||||
#[doc(hidden)]
|
||||
|
|
|
@ -72,7 +72,7 @@ impl<'a> BytesReader<'a> {
|
|||
|
||||
#[inline]
|
||||
pub fn peek(&self) -> Option<u8> {
|
||||
self.remaining().get(0).copied()
|
||||
self.remaining().first().copied()
|
||||
}
|
||||
#[inline]
|
||||
pub fn span(&self, span: Span) -> &[u8] {
|
||||
|
|
|
@ -115,7 +115,7 @@ impl<'a> Lexer<'a> {
|
|||
/// otherwise.
|
||||
pub fn lex_hex(&mut self, amount: u8) -> bool {
|
||||
for _ in 0..amount {
|
||||
if !self.eat_when(|x| matches!(x,b'0'..=b'9' | b'a'..=b'f' | b'A'..=b'F')) {
|
||||
if !self.eat_when(|x| x.is_ascii_hexdigit()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue