Add simple Redis Server which is only capable of doing publish / subscribe. New ws redis_server sub-command to use it. The server is used in the unittest, so that we can run on CI in environment where redis isn not available like github actions env.
This commit is contained in:
@ -47,6 +47,7 @@ add_executable(ws
|
||||
ws_receive.cpp
|
||||
ws_redis_publish.cpp
|
||||
ws_redis_subscribe.cpp
|
||||
ws_redis_server.cpp
|
||||
ws_snake.cpp
|
||||
ws_cobra_subscribe.cpp
|
||||
ws_cobra_metrics_publish.cpp
|
||||
|
@ -243,6 +243,10 @@ int main(int argc, char** argv)
|
||||
autobahnApp->add_option("--url", url, "url");
|
||||
autobahnApp->add_flag("-q", quiet, "Quiet");
|
||||
|
||||
CLI::App* redisServerApp = app.add_subcommand("redis_server", "Redis server");
|
||||
redisServerApp->add_option("--port", port, "Port");
|
||||
redisServerApp->add_option("--host", hostname, "Hostname");
|
||||
|
||||
CLI11_PARSE(app, argc, argv);
|
||||
|
||||
// pid file handling
|
||||
@ -364,6 +368,10 @@ int main(int argc, char** argv)
|
||||
{
|
||||
ret = ix::ws_autobahn_main(url, quiet);
|
||||
}
|
||||
else if (app.got_subcommand("redis_server"))
|
||||
{
|
||||
ret = ix::ws_redis_server_main(port, hostname);
|
||||
}
|
||||
|
||||
ix::uninitNetSystem();
|
||||
return ret;
|
||||
|
2
ws/ws.h
2
ws/ws.h
@ -111,4 +111,6 @@ namespace ix
|
||||
int ws_httpd_main(int port, const std::string& hostname);
|
||||
|
||||
int ws_autobahn_main(const std::string& url, bool quiet);
|
||||
|
||||
int ws_redis_server_main(int port, const std::string& hostname);
|
||||
} // namespace ix
|
||||
|
@ -4,8 +4,8 @@
|
||||
* Copyright (c) 2019 Machine Zone, Inc. All rights reserved.
|
||||
*/
|
||||
|
||||
#include <ixsnake/IXRedisClient.h>
|
||||
#include <iostream>
|
||||
#include <ixsnake/IXRedisClient.h>
|
||||
#include <sstream>
|
||||
|
||||
namespace ix
|
||||
|
32
ws/ws_redis_server.cpp
Normal file
32
ws/ws_redis_server.cpp
Normal file
@ -0,0 +1,32 @@
|
||||
/*
|
||||
* ws_redis_publish.cpp
|
||||
* Author: Benjamin Sergeant
|
||||
* Copyright (c) 2019 Machine Zone, Inc. All rights reserved.
|
||||
*/
|
||||
|
||||
#include <iostream>
|
||||
#include <ixsnake/IXRedisServer.h>
|
||||
#include <spdlog/spdlog.h>
|
||||
#include <sstream>
|
||||
|
||||
namespace ix
|
||||
{
|
||||
int ws_redis_server_main(int port, const std::string& hostname)
|
||||
{
|
||||
spdlog::info("Listening on {}:{}", hostname, port);
|
||||
|
||||
ix::RedisServer server(port, hostname);
|
||||
|
||||
auto res = server.listen();
|
||||
if (!res.first)
|
||||
{
|
||||
std::cerr << res.second << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
server.start();
|
||||
server.wait();
|
||||
|
||||
return 0;
|
||||
}
|
||||
} // namespace ix
|
@ -4,10 +4,10 @@
|
||||
* Copyright (c) 2019 Machine Zone, Inc. All rights reserved.
|
||||
*/
|
||||
|
||||
#include <ixsnake/IXRedisClient.h>
|
||||
#include <atomic>
|
||||
#include <chrono>
|
||||
#include <iostream>
|
||||
#include <ixsnake/IXRedisClient.h>
|
||||
#include <sstream>
|
||||
#include <thread>
|
||||
|
||||
|
@ -4,9 +4,9 @@
|
||||
* Copyright (c) 2018 Machine Zone, Inc. All rights reserved.
|
||||
*/
|
||||
|
||||
#include <ixsnake/IXSnakeServer.h>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <ixsnake/IXSnakeServer.h>
|
||||
#include <sstream>
|
||||
|
||||
namespace
|
||||
|
Reference in New Issue
Block a user