book_manage/packages/tus/src/utils/models/Context.ts

15 lines
514 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
* 本模块定义了CancellationContext接口用于管理请求的终止机制。
* 该接口提供了两种请求终止方式:立即中止和优雅取消,适用于需要精细控制请求生命周期的场景。
*
* 使用场景:
* - 文件上传/下载过程中出现错误需要立即停止
* - 用户主动取消长时间运行的请求
* - 需要优雅关闭资源连接的场景
*/
export interface CancellationContext {
signal: AbortSignal
abort: () => void
cancel: () => void
}