feat(task): add task support (SEP-1686) (#536)
Signed-off-by: jokemanfire <hu.dingyang@zte.com.cn>
This commit is contained in:
parent
eeacd1375f
commit
621c9f619e
1 changed files with 1922 additions and 57 deletions
|
|
@ -5,6 +5,7 @@ mod common;
|
|||
mod prompt;
|
||||
mod prompt_handler;
|
||||
mod prompt_router;
|
||||
mod task_handler;
|
||||
mod tool;
|
||||
mod tool_handler;
|
||||
mod tool_router;
|
||||
|
|
@ -263,3 +264,17 @@ pub fn prompt_handler(attr: TokenStream, input: TokenStream) -> TokenStream {
|
|||
.unwrap_or_else(|err| err.to_compile_error())
|
||||
.into()
|
||||
}
|
||||
|
||||
/// # task_handler
|
||||
///
|
||||
/// Generates basic task-handling methods (`enqueue_task` and `list_tasks`) for a server handler
|
||||
/// using a shared \[`OperationProcessor`\]. The default processor expression assumes a
|
||||
/// `self.processor` field holding an `Arc<Mutex<OperationProcessor>>`, but it can be customized
|
||||
/// via `#[task_handler(processor = ...)]`. Because the macro captures `self` inside spawned
|
||||
/// futures, the handler type must implement [`Clone`].
|
||||
#[proc_macro_attribute]
|
||||
pub fn task_handler(attr: TokenStream, input: TokenStream) -> TokenStream {
|
||||
task_handler::task_handler(attr.into(), input.into())
|
||||
.unwrap_or_else(|err| err.to_compile_error())
|
||||
.into()
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue