Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add postgresql support #187

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions matchengine/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,18 @@
},
"cli": "tcp@127.0.0.1:7317",
"db_log": {
"read_db_type": "mysql",
"write_db_type": "all",
"pg_conninfo":"host=localhost port=5432 user=user password=pass dbname=trade_log",
"host": "localhost",
"user": "user",
"pass": "pass",
"name": "trade_log"
},
"db_history": {
"read_db_type": "postgresql",
"write_db_type": "postgresql",
"pg_conninfo":"host=localhost port=5432 user=user password=pass dbname=trade_history",
"host": "localhost",
"user": "user",
"pass": "pass",
Expand Down
5 changes: 3 additions & 2 deletions matchengine/makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
TARGET := matchengine.exe
INCS = -I ../network -I ../utils
LIBS = -L ../utils -lutils -L ../network -lnetwork -Wl,-Bstatic -lev -ljansson -lmpdec -lmysqlclient -lz -lrdkafka -lssl -lcrypto -lhiredis -Wl,-Bdynamic -lm -lpthread -ldl
PQ = `/usr/bin/pkg-config --cflags --libs libpq`
INCS = -I ../network -I ../utils $(PQ)
LIBS = -L ../utils -lutils -L ../network -lnetwork -Wl,-Bstatic -lev -ljansson -lmpdec -lmysqlclient -lz -lrdkafka -lssl -lcrypto -lhiredis -Wl,-Bdynamic -lm -lpthread -ldl $(PQ)
include ../makefile.inc
4 changes: 2 additions & 2 deletions matchengine/me_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,12 @@ static int read_config_from_json(json_t *root)
printf("load cli config fail: %d\n", ret);
return -__LINE__;
}
ret = load_cfg_mysql(root, "db_log", &settings.db_log);
ret = load_cfg_database(root, "db_log", &settings.db_log);
if (ret < 0) {
printf("load log db config fail: %d\n", ret);
return -__LINE__;
}
ret = load_cfg_mysql(root, "db_history", &settings.db_history);
ret = load_cfg_database(root, "db_history", &settings.db_history);
if (ret < 0) {
printf("load history db config fail: %d\n", ret);
return -__LINE__;
Expand Down
5 changes: 3 additions & 2 deletions matchengine/me_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
# include "ut_misc.h"
# include "ut_list.h"
# include "ut_mysql.h"
# include "ut_database.h"
# include "ut_signal.h"
# include "ut_define.h"
# include "ut_config.h"
Expand Down Expand Up @@ -71,8 +72,8 @@ struct settings {
alert_cfg alert;
rpc_svr_cfg svr;
cli_svr_cfg cli;
mysql_cfg db_log;
mysql_cfg db_history;
database_cfg db_log;
database_cfg db_history;

size_t asset_num;
struct asset *assets;
Expand Down
Loading