Skip to content

Commit

Permalink
feat: allow the start graph action to return a failure error
Browse files Browse the repository at this point in the history
  • Loading branch information
halajohn committed Jan 8, 2025
1 parent f37b5b3 commit c595420
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 30 deletions.
6 changes: 3 additions & 3 deletions core/include_internal/ten_runtime/app/msg_interface/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ typedef struct ten_engine_t ten_engine_t;
TEN_RUNTIME_PRIVATE_API void ten_app_push_to_in_msgs_queue(
ten_app_t *self, ten_shared_ptr_t *msg);

TEN_RUNTIME_PRIVATE_API bool ten_app_handle_out_msg(ten_app_t *self,
ten_shared_ptr_t *msg,
ten_error_t *err);
TEN_RUNTIME_PRIVATE_API bool ten_app_dispatch_msg(ten_app_t *self,
ten_shared_ptr_t *msg,
ten_error_t *err);

TEN_RUNTIME_PRIVATE_API bool ten_app_handle_in_msg(ten_app_t *self,
ten_connection_t *connection,
Expand Down
2 changes: 1 addition & 1 deletion core/include_internal/ten_runtime/extension/extension.h
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ TEN_RUNTIME_PRIVATE_API ten_path_in_t *
ten_extension_get_cmd_return_path_from_itself(ten_extension_t *self,
const char *cmd_id);

TEN_RUNTIME_PRIVATE_API bool ten_extension_handle_out_msg(
TEN_RUNTIME_PRIVATE_API bool ten_extension_dispatch_msg(
ten_extension_t *extension, ten_shared_ptr_t *msg, ten_error_t *err);

TEN_RUNTIME_PRIVATE_API ten_runloop_t *ten_extension_get_attached_runloop(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@

typedef struct ten_extension_group_t ten_extension_group_t;

TEN_RUNTIME_PRIVATE_API bool ten_extension_group_handle_out_msg(
TEN_RUNTIME_PRIVATE_API bool ten_extension_group_dispatch_msg(
ten_extension_group_t *self, ten_shared_ptr_t *msg, ten_error_t *err);
4 changes: 2 additions & 2 deletions core/src/ten_runtime/app/msg_interface/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -274,8 +274,8 @@ static bool ten_app_handle_stop_graph_cmd(ten_app_t *self,
return true;
}

bool ten_app_handle_out_msg(ten_app_t *self, ten_shared_ptr_t *msg,
ten_error_t *err) {
bool ten_app_dispatch_msg(ten_app_t *self, ten_shared_ptr_t *msg,
ten_error_t *err) {
// The source of the out message is the current app.
ten_msg_set_src_to_app(msg, self);

Expand Down
15 changes: 3 additions & 12 deletions core/src/ten_runtime/extension/extension.c
Original file line number Diff line number Diff line change
Expand Up @@ -611,17 +611,8 @@ static TEN_EXTENSION_DETERMINE_OUT_MSGS_RESULT ten_extension_determine_out_msgs(
}
}

static void ten_extension_dispatch_msg(ten_extension_t *self,
ten_shared_ptr_t *msg) {
TEN_ASSERT(self && ten_extension_check_integrity(self, true) && msg &&
ten_msg_check_integrity(msg),
"Should not happen.");

ten_extension_thread_dispatch_msg(self->extension_thread, msg);
}

bool ten_extension_handle_out_msg(ten_extension_t *self, ten_shared_ptr_t *msg,
ten_error_t *err) {
bool ten_extension_dispatch_msg(ten_extension_t *self, ten_shared_ptr_t *msg,
ten_error_t *err) {
TEN_ASSERT(self && ten_extension_check_integrity(self, true),
"Should not happen.");
TEN_ASSERT(msg && ten_msg_check_integrity(msg), "Should not happen.");
Expand Down Expand Up @@ -739,7 +730,7 @@ bool ten_extension_handle_out_msg(ten_extension_t *self, ten_shared_ptr_t *msg,
TEN_ASSERT(result_msg && ten_msg_check_integrity(result_msg),
"Invalid argument.");

ten_extension_dispatch_msg(self, result_msg);
ten_extension_thread_dispatch_msg(self->extension_thread, msg);
}

done:
Expand Down
6 changes: 2 additions & 4 deletions core/src/ten_runtime/extension_group/msg_interface/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,8 @@
#include "include_internal/ten_runtime/extension_group/extension_group.h"
#include "include_internal/ten_runtime/msg/msg.h"

// =-=-= handle_out_msg 统一成 dispatch_msg?
bool ten_extension_group_handle_out_msg(ten_extension_group_t *self,
ten_shared_ptr_t *msg,
ten_error_t *err) {
bool ten_extension_group_dispatch_msg(ten_extension_group_t *self,
ten_shared_ptr_t *msg, ten_error_t *err) {
ten_msg_set_src_to_extension_group(msg, self);

ten_loc_t *dest_loc = ten_msg_get_first_dest_loc(msg);
Expand Down
5 changes: 2 additions & 3 deletions core/src/ten_runtime/ten_env/internal/return.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ static bool ten_env_return_result_internal(
TEN_ASSERT(extension && ten_extension_check_integrity(extension, true),
"Invalid use of extension %p.", extension);

result = ten_extension_handle_out_msg(extension, result_cmd, err);
result = ten_extension_dispatch_msg(extension, result_cmd, err);
break;
}

Expand All @@ -68,9 +68,8 @@ static bool ten_env_return_result_internal(
ten_extension_group_check_integrity(extension_group, true),
"Invalid use of extension_group %p.", extension_group);

// =-=-=
result =
ten_extension_group_handle_out_msg(extension_group, result_cmd, err);
ten_extension_group_dispatch_msg(extension_group, result_cmd, err);
break;
}

Expand Down
7 changes: 3 additions & 4 deletions core/src/ten_runtime/ten_env/internal/send.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ static bool ten_send_msg_internal(
ten_extension_t *extension = ten_env_get_attached_extension(self);
TEN_ASSERT(extension, "Should not happen.");

result = ten_extension_handle_out_msg(extension, msg, err);
result = ten_extension_dispatch_msg(extension, msg, err);
break;
}

Expand All @@ -112,8 +112,7 @@ static bool ten_send_msg_internal(
ten_env_get_attached_extension_group(self);
TEN_ASSERT(extension_group, "Should not happen.");

// =-=-=
result = ten_extension_group_handle_out_msg(extension_group, msg, err);
result = ten_extension_group_dispatch_msg(extension_group, msg, err);
break;
}

Expand All @@ -129,7 +128,7 @@ static bool ten_send_msg_internal(
ten_app_t *app = ten_env_get_attached_app(self);
TEN_ASSERT(app, "Should not happen.");

result = ten_app_handle_out_msg(app, msg, err);
result = ten_app_dispatch_msg(app, msg, err);
break;
}

Expand Down

0 comments on commit c595420

Please sign in to comment.