Fix `HEYA` impl and add `HEYA` actiondoc

Also added heya echo test
next
Sayan Nandan 3 years ago
parent 687ee0cb4c
commit d744eaa2f6

@ -109,10 +109,12 @@ All changes in this project will be noted in this file.
to follow the `MGET`/`GET` naming convention
- TLS port can now be set to a custom port via CLI arguments
- `sky-bench` can now run multiple times to get average values through the `--runs` option
- `HEYA` now does an echo with the second argument
### Fixes
- Zero length argument causing runtime panic in `skysh`
- `HEYA!` not reporting errors on incorrect number of arguments
- Panic on incorrect data type in `skyd`
- `sky-bench` no longer affects your personal data because it creates a random temporary table
under the `default` keyspace

@ -158,10 +158,17 @@
accept: [AnyArray]
syntax: [POP <key1> <key2> ...]
desc: |
Deletes and returns the values of the provided keys from the current table. If the database is poisoned,
this will return a server error. An exceptional scenario can arise when the database
fails in-between removing all the keys. In that case, you get the server error
response code instead of the keys. If the server recovers inbetween, then the
appropriate values (if any) will be returned. In all other cases a NIL error is
Deletes and returns the values of the provided 'n' keys from the current table.
If the database is poisoned, this will return a server error. An exceptional scenario
can arise when the database fails in-between removing all the keys. In that case, you
get the server error response code instead of the keys. If the server recovers inbetween,
then the appropriate values (if any) will be returned. In all other cases a NIL error is
returned (code 1)
return: [Flat Array]
- name: HEYA
complexity: O(1)
accept: [AnyArray]
syntax: [HEYA, HEYA <message>]
desc: |
Either returns a "HEY!" or returns the provided argument as a String
return: [String]

@ -50,10 +50,17 @@ pub mod uset;
pub mod heya {
//! Respond to `HEYA` queries
use crate::dbnet::connection::prelude::*;
use crate::resp::BytesWrapper;
action!(
/// Returns a `HEY!` `Response`
fn heya(_handle: &Corestore, con: &mut T, _act: ActionIter) {
con.write_response(responses::groups::HEYA).await
fn heya(_handle: &Corestore, con: &mut T, mut act: ActionIter) {
err_if_len_is!(act, con, gt 1);
if act.len() == 1 {
let raw_byte = unsafe { act.next().unsafe_unwrap() };
con.write_response(BytesWrapper(raw_byte)).await
} else {
con.write_response(responses::groups::HEYA).await
}
}
);
}

@ -59,6 +59,13 @@ mod __private {
assert_eq!(resp, Response::Item(Element::Str("HEY!".to_owned())));
}
async fn test_heya_echo() {
query.push("heya");
query.push("sayan");
let resp = con.run_simple_query(&query).await.unwrap();
assert_eq!(resp, Response::Item(Element::Str("sayan".to_owned())));
}
/// Test a GET query: for a non-existing key
async fn test_get_single_nil() {
query.push("get");

Loading…
Cancel
Save