支持promise finish。

This commit is contained in:
zhangchengwei
2018-11-23 20:55:28 +08:00
committed by zhengchao
parent 313f36c58a
commit 9fc2a8a0d2
8 changed files with 85 additions and 29 deletions

View File

@@ -266,19 +266,19 @@ static void redis_hget_command_cb(struct redisAsyncContext *ac, void *vreply, vo
{
tango_cache_set_fail_state(ctx, CACHE_CACHE_MISS);
ctx->get.result.type = RESULT_TYPE_MISS;
promise_success(future_to_promise(ctx->future), &ctx->get.result);
promise_success(ctx->promise, &ctx->get.result);
promise_finish(ctx->promise);
}
else
{
tango_cache_set_fail_state(ctx, CACHE_ERR_REDIS_JSON);
if(reply!=NULL && reply->type==REDIS_REPLY_ERROR)
{
promise_failed(future_to_promise(ctx->future), FUTURE_ERROR_CANCEL, reply->str);
promise_failed(ctx->promise, FUTURE_ERROR_CANCEL, reply->str);
}
else
{
promise_failed(future_to_promise(ctx->future), FUTURE_ERROR_CANCEL, tango_cache_get_errstring(ctx));
promise_failed(ctx->promise, FUTURE_ERROR_CANCEL, tango_cache_get_errstring(ctx));
}
}
tango_cache_ctx_destroy(ctx);
@@ -290,7 +290,7 @@ static void redis_hget_command_cb(struct redisAsyncContext *ac, void *vreply, vo
{
case PARSE_JSON_RET_ERROR:
tango_cache_set_fail_state(ctx, CACHE_ERR_REDIS_JSON);
promise_failed(future_to_promise(ctx->future), FUTURE_ERROR_CANCEL, tango_cache_get_errstring(ctx));
promise_failed(ctx->promise, FUTURE_ERROR_CANCEL, tango_cache_get_errstring(ctx));
tango_cache_ctx_destroy(ctx);
break;
case PARSE_JSON_RET_TIMEOUT:
@@ -303,7 +303,8 @@ static void redis_hget_command_cb(struct redisAsyncContext *ac, void *vreply, vo
case PARSE_JSON_RET_SUCC:
fetch_header_over_biz(ctx);
ctx->get.result.type = RESULT_TYPE_END;
promise_success(future_to_promise(ctx->future), &ctx->get.result);
promise_success(ctx->promise, &ctx->get.result);
promise_finish(ctx->promise);
tango_cache_ctx_destroy(ctx);
break;
default: assert(0);break;