-
Notifications
You must be signed in to change notification settings - Fork 6
/
waid.cpp
32 lines (30 loc) · 867 Bytes
/
waid.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <stdio.h>
#include "mongo.h"
#include "bson.h"
int main(int argc, char **argv)
{
mongo conn;
int status = mongo_connect(&conn, "127.0.0.1", 27017);
if (status != MONGO_OK) {
printf("connection failed.\n");
return -1;
}
bson query;
bson_init(&query);
bson_append_int(&query, "status", 0);
bson_finish(&query);
mongo_cursor cursor;
mongo_cursor_init(&cursor, &conn, "wai.submits");
mongo_cursor_set_query(&cursor, &query);
while (mongo_cursor_next(&cursor) == MONGO_OK) {
printf("===========================\n");
bson_print(&(cursor.current));
}
bson_destroy(&query);
mongo_cursor_destroy(&cursor);
mongo_destroy(&conn);
// 1. Create Deamon
// 2. poll query in database, compiling uncompiled source file
// 3. call Scheduler::GetMatch(), and build match, get result, fill in the db
return 0;
}