2016-11-10 18:13:26 -08:00
|
|
|
#include "task_table.h"
|
|
|
|
#include "redis.h"
|
|
|
|
|
|
|
|
#define NUM_DB_REQUESTS 2
|
|
|
|
|
|
|
|
void task_table_get_task(db_handle *db_handle,
|
|
|
|
task_id task_id,
|
|
|
|
retry_info *retry,
|
|
|
|
task_table_get_callback done_callback,
|
|
|
|
void *user_context) {
|
2016-11-15 20:33:29 -08:00
|
|
|
init_table_callback(db_handle, task_id, __func__, NULL, retry, done_callback,
|
2016-11-10 18:13:26 -08:00
|
|
|
redis_task_table_get_task, user_context);
|
|
|
|
}
|
|
|
|
|
|
|
|
void task_table_add_task(db_handle *db_handle,
|
2016-12-03 13:49:09 -08:00
|
|
|
OWNER task *task,
|
2016-11-10 18:13:26 -08:00
|
|
|
retry_info *retry,
|
|
|
|
task_table_done_callback done_callback,
|
|
|
|
void *user_context) {
|
2016-11-15 20:33:29 -08:00
|
|
|
init_table_callback(db_handle, task_task_id(task), __func__, task, retry,
|
|
|
|
done_callback, redis_task_table_add_task, user_context);
|
2016-11-10 18:13:26 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
void task_table_update(db_handle *db_handle,
|
2016-12-03 13:49:09 -08:00
|
|
|
OWNER task *task,
|
2016-11-10 18:13:26 -08:00
|
|
|
retry_info *retry,
|
|
|
|
task_table_done_callback done_callback,
|
|
|
|
void *user_context) {
|
2016-11-15 20:33:29 -08:00
|
|
|
init_table_callback(db_handle, task_task_id(task), __func__, task, retry,
|
|
|
|
done_callback, redis_task_table_update, user_context);
|
2016-11-10 18:13:26 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* TODO(swang): A corresponding task_table_unsubscribe. */
|
|
|
|
void task_table_subscribe(db_handle *db_handle,
|
|
|
|
node_id node,
|
|
|
|
scheduling_state state_filter,
|
|
|
|
task_table_subscribe_callback subscribe_callback,
|
|
|
|
void *subscribe_context,
|
|
|
|
retry_info *retry,
|
|
|
|
task_table_done_callback done_callback,
|
|
|
|
void *user_context) {
|
|
|
|
task_table_subscribe_data *sub_data =
|
|
|
|
malloc(sizeof(task_table_subscribe_data));
|
|
|
|
sub_data->node = node;
|
|
|
|
sub_data->state_filter = state_filter;
|
|
|
|
sub_data->subscribe_callback = subscribe_callback;
|
|
|
|
sub_data->subscribe_context = subscribe_context;
|
|
|
|
|
2016-11-15 20:33:29 -08:00
|
|
|
init_table_callback(db_handle, node, __func__, sub_data, retry, done_callback,
|
2016-11-10 18:13:26 -08:00
|
|
|
redis_task_table_subscribe, user_context);
|
|
|
|
}
|