mirror of
https://github.com/dragonflydb/dragonfly.git
synced 2025-05-11 10:25:47 +02:00
server family: add connection set name command fixes #458 Signed-off-by: adi_holden <adi@dragonflydb.io>
This commit is contained in:
parent
c9c33b476b
commit
b395834060
3 changed files with 18 additions and 1 deletions
|
@ -157,7 +157,7 @@ with respect to Memcached and Redis APIs.
|
|||
- [X] WATCH
|
||||
- [X] UNWATCH
|
||||
- [X] DISCARD
|
||||
- [X] CLIENT LIST/SETNAME
|
||||
- [X] CLIENT LIST/SETNAME/GETNAME
|
||||
- [ ] CLIENT KILL/UNPAUSE/PAUSE/GETNAME/REPLY/TRACKINGINFO
|
||||
- [X] COMMAND
|
||||
- [X] COMMAND COUNT
|
||||
|
|
|
@ -1040,6 +1040,15 @@ void ServerFamily::Client(CmdArgList args, ConnectionContext* cntx) {
|
|||
return (*cntx)->SendOk();
|
||||
}
|
||||
|
||||
if (sub_cmd == "GETNAME") {
|
||||
const char* name = cntx->owner()->GetName();
|
||||
if (*name != 0) {
|
||||
return (*cntx)->SendBulkString(name);
|
||||
} else {
|
||||
return (*cntx)->SendNull();
|
||||
}
|
||||
}
|
||||
|
||||
if (sub_cmd == "LIST") {
|
||||
vector<string> client_info;
|
||||
fibers::mutex mu;
|
||||
|
|
|
@ -52,3 +52,11 @@ def test_multi_eval(client):
|
|||
except Exception as e:
|
||||
msg = str(e)
|
||||
assert "Dragonfly does not allow execution of" in msg
|
||||
|
||||
|
||||
def test_connection_name(client):
|
||||
name = client.execute_command("CLIENT GETNAME")
|
||||
assert not name
|
||||
client.execute_command("CLIENT SETNAME test_conn_name")
|
||||
name = client.execute_command("CLIENT GETNAME")
|
||||
assert name == "test_conn_name"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue