the log.hh under the root of the tree was created keep the backward compatibility when seastar was extracted into a separate library. so log.hh should belong to `utils` directory, as it is based solely on seastar, and can be used all subsystems. in this change, we move log.hh into utils/log.hh to that it is more modularized. and this also improves the readability, when one see `#include "utils/log.hh"`, it is obvious that this source file needs the logging system, instead of its own log facility -- please note, we do have two other `log.hh` in the tree. Signed-off-by: Kefu Chai <kefu.chai@scylladb.com>
49 lines
1.6 KiB
C++
49 lines
1.6 KiB
C++
/*
|
|
* Copyright (C) 2019 pengjian.uestc @ gmail.com
|
|
*/
|
|
|
|
/*
|
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
|
*/
|
|
|
|
#include "redis/command_factory.hh"
|
|
#include "service/storage_proxy.hh"
|
|
#include "redis/commands.hh"
|
|
#include "utils/log.hh"
|
|
|
|
namespace redis {
|
|
|
|
static logging::logger logging("command_factory");
|
|
|
|
future<redis_message> command_factory::create_execute(service::storage_proxy& proxy, request& req, redis::redis_options& options, service_permit permit)
|
|
{
|
|
static thread_local std::unordered_map<bytes, std::function<future<redis_message> (service::storage_proxy& proxy, request& req, redis::redis_options& options, service_permit permit)>> _commands =
|
|
{
|
|
{ "ping", commands::ping },
|
|
{ "select", commands::select },
|
|
{ "get", commands::get },
|
|
{ "exists", commands::exists },
|
|
{ "ttl", commands::ttl },
|
|
{ "strlen", commands::strlen },
|
|
{ "set", commands::set },
|
|
{ "setex", commands::setex },
|
|
{ "del", commands::del },
|
|
{ "echo", commands::echo },
|
|
{ "lolwut", commands::lolwut },
|
|
{ "hget", commands::hget },
|
|
{ "hset", commands::hset },
|
|
{ "hgetall", commands::hgetall },
|
|
{ "hdel", commands::hdel },
|
|
{ "hexists", commands::hexists },
|
|
};
|
|
auto&& command = _commands.find(req._command);
|
|
if (command != _commands.end()) {
|
|
return (command->second)(proxy, req, options, permit);
|
|
}
|
|
auto& b = req._command;
|
|
logging.error("receive unknown command = {}", sstring(reinterpret_cast<const char*>(b.data()), b.size()));
|
|
return commands::unknown(proxy, req, options, permit);
|
|
}
|
|
|
|
}
|