eXtremeDB_rt/samples/realtime_rest/
This sample demonstrates the initialization, start, operation, and shutdown of the RESTrt service. It can be utilized with xPanel to monitor database statistics (realtime counters).
The sample establishes a database, incorporates several "sensors" and updates their values in real-time transactions, simulating scenarios where some updates fail to meet the real-time deadline. A separate thread simulates the analysis of sensor data.
mcorest_initialize(), mcorest_start(), mcorest_shutdown()
static void rest_loop_task(void *args) { MCO_RET rc; mco_sock_params_t s_params; mco_socket_params_init(&s_params); s_params.mode = MCO_SOCK_NON_BLOCKING; rc = mcorest_initialize(db_name, INTERFACE, PORT, &s_params); if (rc != MCO_S_OK) { printf("ERROR: mcorest_initialize() failed: %d (%s)\n", rc, mco_strerror(rc)); return; } printf("Starting rest on port %d...\n", PORT); rc = mcorest_start(); if (rc != MCO_S_OK) { printf("ERROR: mcorest_start() failed: %d (%s)\n", rc, mco_strerror(rc)); return; } mcorest_shutdown(); printf("REST loop task done\n"); }