From 88955b62c6b0d42d2b0399fa17dca87e410a7c54 Mon Sep 17 00:00:00 2001 From: Sayan Nandan Date: Sat, 12 Mar 2022 06:09:35 -0800 Subject: [PATCH] Add changelog and remove unused code --- CHANGELOG.md | 12 ++++++++++++ server/src/corestore/memstore.rs | 22 ++-------------------- server/src/tests/auth.rs | 4 ++-- server/src/util/macros.rs | 21 --------------------- 4 files changed, 16 insertions(+), 43 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3ff93686..cbf2e929 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,18 @@ All changes in this project will be noted in this file. +## Unreleased + +### Additions + +- Token-based authentication: + - `auth claim` + - `auth login ` + - `auth logout` + - `auth adduser ` + - `auth deluser ` +- Shell now supports multiple `--eval` expressions + ## Version 0.7.3 ### Additions diff --git a/server/src/corestore/memstore.rs b/server/src/corestore/memstore.rs index ec86e534..e3955489 100644 --- a/server/src/corestore/memstore.rs +++ b/server/src/corestore/memstore.rs @@ -54,21 +54,16 @@ //! So, all your data is at the mercy of [`Memstore`]'s constructor //! and destructor. -#![allow(unused)] // TODO(@ohsayan): Plonk this - use super::KeyspaceResult; use crate::auth::Authmap; use crate::corestore::array::Array; use crate::corestore::htable::Coremap; -use crate::corestore::lock::{QLGuard, QuickLock}; use crate::corestore::table::Table; use crate::corestore::table::{SystemDataModel, SystemTable}; use crate::registry; use crate::util::Wrapper; use core::borrow::Borrow; use core::hash::Hash; -use core::mem::MaybeUninit; -use core::ops::Deref; use std::sync::Arc; uninit_array! { @@ -173,6 +168,7 @@ pub struct Memstore { impl Memstore { /// Create a new empty in-memory table with literally nothing in it + #[cfg(test)] pub fn new_empty() -> Self { Self { keyspaces: Coremap::new(), @@ -225,6 +221,7 @@ impl Memstore { } None => match self.system.tables.get(&AUTH).unwrap().data { SystemDataModel::Auth(ref am) => am.clone(), + #[allow(unreachable_patterns)] _ => unsafe { impossible!() }, }, } @@ -346,8 +343,6 @@ pub struct Keyspace { /// the replication strategy for this keyspace #[allow(dead_code)] // TODO: Remove this once we're ready with replication replication_strategy: cluster::ReplicationStrategy, - /// A **virtual lock** on the partmap for this keyspace - partmap_lock: QuickLock<()>, } #[cfg(test)] @@ -368,14 +363,12 @@ impl Keyspace { ht }, replication_strategy: cluster::ReplicationStrategy::default(), - partmap_lock: QuickLock::new(()), } } pub fn init_with_all_def_strategy(tables: Coremap>) -> Self { Self { tables, replication_strategy: cluster::ReplicationStrategy::default(), - partmap_lock: QuickLock::new(()), } } /// Create a new empty keyspace with zero tables @@ -383,7 +376,6 @@ impl Keyspace { Self { tables: Coremap::new(), replication_strategy: cluster::ReplicationStrategy::default(), - partmap_lock: QuickLock::new(()), } } pub fn table_count(&self) -> usize { @@ -434,16 +426,6 @@ impl Keyspace { } } } - - /// Remove a table without doing any reference checks. This will just pull it off - pub unsafe fn force_remove_table(&self, tblid: &ObjectID) { - // atomic remember? nobody cares about the result - self.tables.remove(tblid); - } - - pub fn lock_partmap(&self) -> QLGuard<'_, ()> { - self.partmap_lock.lock() - } } #[test] diff --git a/server/src/tests/auth.rs b/server/src/tests/auth.rs index 960a0739..522166fb 100644 --- a/server/src/tests/auth.rs +++ b/server/src/tests/auth.rs @@ -244,12 +244,12 @@ mod syntax_checks { ONLYAUTH ); } - #[sky_macros::dbtest_func(port = 2005, norun = true)] + #[sky_macros::dbtest_func(port = 2005, norun = true, auth_testuser = true)] async fn unknown_auth_action() { runeq!( con, query!("auth", "raspberry"), - Element::RespCode(RespCode::ErrorString("unknown-action".to_owned())) + Element::RespCode(RespCode::ErrorString("Unknown action".to_owned())) ) } } diff --git a/server/src/util/macros.rs b/server/src/util/macros.rs index 264a8237..a5149ab5 100644 --- a/server/src/util/macros.rs +++ b/server/src/util/macros.rs @@ -142,27 +142,6 @@ macro_rules! action { }; } -#[allow(unused_macros)] // TODO(@ohsayan): Remove this if we don't need it anymore -macro_rules! afn_action { - ( - $($(#[$attr:meta])* - fn $fname:ident($($argname:ident: $argty:ty),*) - $block:block)* - ) => { - $( - $(#[$attr])* - fn $fname<'a, T: 'a, Strm: 'a>($($argname: $argty,)*) -> - core::pin::Pin> + Send + Sync + 'a>> - where - T: ProtocolConnectionExt + Send + Sync, - Strm: AsyncReadExt + AsyncWriteExt + Unpin + Send + Sync - { - std::boxed::Box::pin(async move {$block}) - } - )* - }; -} - #[macro_export] macro_rules! byt { ($f:expr) => {