mirror of https://github.com/yandex/odyssey.git
odissey: add console query parser function
This commit is contained in:
parent
46d9981afa
commit
c89a687490
|
@ -97,8 +97,6 @@ typedef struct
|
||||||
uint64_t version;
|
uint64_t version;
|
||||||
} od_config_t;
|
} od_config_t;
|
||||||
|
|
||||||
#define od_keyword(name, token) { token, name, sizeof(name) - 1 }
|
|
||||||
|
|
||||||
static od_keyword_t od_config_keywords[] =
|
static od_keyword_t od_config_keywords[] =
|
||||||
{
|
{
|
||||||
/* main */
|
/* main */
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
|
#include <ctype.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
|
||||||
#include <machinarium.h>
|
#include <machinarium.h>
|
||||||
|
@ -45,6 +46,7 @@
|
||||||
#include "sources/frontend.h"
|
#include "sources/frontend.h"
|
||||||
#include "sources/backend.h"
|
#include "sources/backend.h"
|
||||||
#include "sources/console.h"
|
#include "sources/console.h"
|
||||||
|
#include "sources/parser.h"
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
|
@ -104,7 +106,6 @@ od_console_show_stats(od_console_t *console, od_msgconsole_t *msg_console)
|
||||||
if (rc == -1)
|
if (rc == -1)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
|
||||||
offset = shapito_be_write_data_row(stream);
|
offset = shapito_be_write_data_row(stream);
|
||||||
rc = shapito_be_write_data_row_add(stream, offset, "test", 4);
|
rc = shapito_be_write_data_row_add(stream, offset, "test", 4);
|
||||||
if (rc == -1)
|
if (rc == -1)
|
||||||
|
@ -139,6 +140,25 @@ od_console_show_stats(od_console_t *console, od_msgconsole_t *msg_console)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
od_console_query(od_console_t *console, od_msgconsole_t *msg_console)
|
||||||
|
{
|
||||||
|
od_instance_t *instance = console->system->instance;
|
||||||
|
od_client_t *client = msg_console->client;
|
||||||
|
|
||||||
|
uint32_t query_len;
|
||||||
|
char *query;
|
||||||
|
shapito_be_read_query(&query, &query_len, msg_console->request,
|
||||||
|
msg_console->request_len);
|
||||||
|
|
||||||
|
od_debug_client(&instance->logger, &client->id, "console",
|
||||||
|
"%.*s", query_len, query);
|
||||||
|
|
||||||
|
int rc;
|
||||||
|
rc = od_console_show_stats(console, msg_console);
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
od_console(void *arg)
|
od_console(void *arg)
|
||||||
{
|
{
|
||||||
|
@ -158,24 +178,13 @@ od_console(void *arg)
|
||||||
{
|
{
|
||||||
od_msgconsole_t *msg_console;
|
od_msgconsole_t *msg_console;
|
||||||
msg_console = machine_msg_get_data(msg);
|
msg_console = machine_msg_get_data(msg);
|
||||||
|
|
||||||
uint32_t query_len;
|
|
||||||
char *query;
|
|
||||||
shapito_be_read_query(&query, &query_len, msg_console->request,
|
|
||||||
msg_console->request_len);
|
|
||||||
|
|
||||||
od_client_t *client = msg_console->client;
|
|
||||||
od_debug_client(&instance->logger, &client->id, "console",
|
|
||||||
"%.*s", query_len, query);
|
|
||||||
|
|
||||||
int rc;
|
int rc;
|
||||||
rc = od_console_show_stats(console, msg_console);
|
rc = od_console_query(console, msg_console);
|
||||||
if (rc == -1) {
|
if (rc == -1) {
|
||||||
msg_console->status = OD_CERROR;
|
msg_console->status = OD_CERROR;
|
||||||
} else {
|
} else {
|
||||||
msg_console->status = OD_COK;
|
msg_console->status = OD_COK;
|
||||||
}
|
}
|
||||||
|
|
||||||
machine_queue_put(msg_console->response, msg);
|
machine_queue_put(msg_console->response, msg);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,6 +40,9 @@ struct od_keyword
|
||||||
int name_len;
|
int name_len;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define od_keyword(name, token) \
|
||||||
|
{ token, name, sizeof(name) - 1 }
|
||||||
|
|
||||||
struct od_parser
|
struct od_parser
|
||||||
{
|
{
|
||||||
char *pos;
|
char *pos;
|
||||||
|
|
Loading…
Reference in New Issue