Use `gen_match!` macro to simplify function calls

Signed-off-by: Sayan Nandan <nandansayan@outlook.com>
next
Sayan Nandan 4 years ago
parent 43779eb08e
commit 65681f38bb
No known key found for this signature in database
GPG Key ID: C31EFD7DDA12AEE0

@ -11,7 +11,7 @@
## What is Skytable?
Skytable (or SkybaseDB/SDB) is an effort to provide the best of key/value stores, document stores and columnar databases, that is, **simplicity, flexibility and queryability at scale**. The name 'Skytable' exemplifies our vision to create a database that has limitless possibilities. Skytable was previously known as TerrabaseDB (and then Skybase).
Skytable is an effort to provide the best of key/value stores, document stores and columnar databases, that is, **simplicity, flexibility and queryability at scale**. The name 'Skytable' exemplifies our vision to create a database that has limitless possibilities. Skytable was previously known as TerrabaseDB (and then Skybase) and is also nicknamed "STable", "Sky" and "SDB" by the community.
Skytable is curently in an alpha stage, but can be used as a **performant**, **secure** and **persistent key-value store**.
@ -23,12 +23,12 @@ Skytable is curently in an alpha stage, but can be used as a **performant**, **s
4. First run `sdb` to start the database server and then run `skysh` to start the interactive shell
5. Run commands like: `SET foo bar` , `GET bar` , `UPDATE cat mitten` or `DEL proprietary` 🤪 on `skysh` !
You can learn more about installation [here](https://terrabasedb.github.io/docs/Getting-Started/)
You can learn more about installation [here](https://skytable.github.io/docs/getting-started/)
## Features
* **Insanely fast**: Scale to millions of queries per second per node
* **Key/value store**: `GET` , `SET` , `UPDATE` and [all that stuff](https://terrabasedb.github.io/docs/List-Of-Actions)
* **Key/value store**: `GET` , `SET` , `UPDATE` and [all that stuff](https://skytable.github.io/docs/actions/overview)
* **Snapshots**: Automated (and tunable) snapshots for stress-free backups
* **Secure**: Secure connections are built into Skytable with SSL/TLS
* **Multithreaded**: Designed to exploit all CPU cores
@ -39,7 +39,7 @@ You can learn more about installation [here](https://terrabasedb.github.io/docs/
## Clients 🔌
Until we release an official driver, you'll have to write your own clients — all you need to do is implement the simple and performant [Terrapipe protocol spec](https://terrabasedb.github.io/docs/Protocols/terrapipe/).
Until we release an official driver, you'll have to write your own clients — all you need to do is implement the simple and performant [Terrapipe protocol spec](https://skytable.github.io/docs/next/protocol/terrapipe).
## Community 👐

@ -28,10 +28,12 @@
use crate::coredb::CoreDB;
use crate::dbnet::Con;
use crate::gen_match;
use crate::protocol::responses;
use crate::protocol::ActionGroup;
use crate::protocol::{responses};
use crate::{admin, kvengine};
use libsky::TResult;
mod tags {
//! This module is a collection of tags/strings used for evaluating queries
//! and responses
@ -81,28 +83,43 @@ pub async fn execute_simple(db: &CoreDB, con: &mut Con<'_>, buf: ActionGroup) ->
}
Some(f) => f.to_uppercase(),
};
match first.as_str() {
tags::TAG_DEL => kvengine::del::del(db, con, buf).await?,
tags::TAG_GET => kvengine::get::get(db, con, buf).await?,
tags::TAG_HEYA => kvengine::heya::heya(db, con, buf).await?,
tags::TAG_EXISTS => kvengine::exists::exists(db, con, buf).await?,
tags::TAG_SET => kvengine::set::set(db, con, buf).await?,
tags::TAG_MGET => kvengine::mget::mget(db, con, buf).await?,
tags::TAG_MSET => kvengine::mset::mset(db, con, buf).await?,
tags::TAG_UPDATE => kvengine::update::update(db, con, buf).await?,
tags::TAG_MUPDATE => kvengine::mupdate::mupdate(db, con, buf).await?,
tags::TAG_SSET => kvengine::strong::sset(db, con, buf).await?,
tags::TAG_SDEL => kvengine::strong::sdel(db, con, buf).await?,
tags::TAG_SUPDATE => kvengine::strong::supdate(db, con, buf).await?,
tags::TAG_DBSIZE => kvengine::dbsize::dbsize(db, con, buf).await?,
tags::TAG_FLUSHDB => kvengine::flushdb::flushdb(db, con, buf).await?,
tags::TAG_USET => kvengine::uset::uset(db, con, buf).await?,
tags::TAG_KEYLEN => kvengine::keylen::keylen(db, con, buf).await?,
tags::TAG_MKSNAP => admin::mksnap::mksnap(db, con, buf).await?,
_ => {
con.write_response(responses::fresp::R_UNKNOWN_ACTION.to_owned())
.await?
}
}
gen_match!(
first,
db,
con,
buf,
tags::TAG_DEL => kvengine::del::del,
tags::TAG_GET => kvengine::get::get,
tags::TAG_HEYA => kvengine::heya::heya,
tags::TAG_EXISTS => kvengine::exists::exists,
tags::TAG_SET => kvengine::set::set,
tags::TAG_MGET => kvengine::mget::mget,
tags::TAG_MSET => kvengine::mset::mset,
tags::TAG_UPDATE => kvengine::update::update,
tags::TAG_MUPDATE => kvengine::mupdate::mupdate,
tags::TAG_SSET => kvengine::strong::sset,
tags::TAG_SDEL => kvengine::strong::sdel,
tags::TAG_SUPDATE => kvengine::strong::supdate,
tags::TAG_DBSIZE => kvengine::dbsize::dbsize,
tags::TAG_FLUSHDB => kvengine::flushdb::flushdb,
tags::TAG_USET => kvengine::uset::uset,
tags::TAG_KEYLEN => kvengine::keylen::keylen,
tags::TAG_MKSNAP => admin::mksnap::mksnap
);
Ok(())
}
#[macro_export]
macro_rules! gen_match {
($pre:ident, $db:ident, $con:ident, $buf:ident, $($x1:ident::$x2:ident => $y1:ident::$y2:ident::$y3:ident),*) => {
match $pre.as_str() {
$(
$x1::$x2 => $y1::$y2::$y3($db, $con, $buf).await?,
)*
_ => {
$con.write_response(responses::fresp::R_UNKNOWN_ACTION.to_owned())
.await?;
},
}
};
}

Loading…
Cancel
Save