/** * @file Context Info Container * @desc 在流程中传递上下文信息,目前主要用于质量上报信息的传递 */ export type ContextValue = { /** 解析是不是走缓存 */ dnsResolveFromCache: boolean; /** 解析请求总耗时,单位秒 */ dnsResolveTotalTime: number; /** 内容下载请求的服务端 IP */ downloadReqIP: string; /** 内容下载请求(在对应的 do 过程中)的重试次数 */ downloadRetryCount: number; /** 内容下载页面(window)线程接收到请求头信息的时间点,单位 ms */ downloadReqMessageAt: number; /** 内容下载请求建立连接时间点,单位 ms */ downloadConnectionAt: number; /** TTFB - Time to First Byte 时间点,单位 ms */ downloadStartTransferAt: number; /** Service Worker 线程接收到响应头信息的时间点,单位 ms */ downloadRespMessageAt: number; /** fileTask ID */ downloadFileTaskID: string; /** 请求发送到的 ECDN 节点的 ID */ downloadEltID: string; /** 页面线程收到 req-head 信息的时间点,单位 ms */ hoWReqMessageAt: number; /** PeerConnection Connect 时间点,单位 ms */ hoWPeerConnectionConnectAt: number; /** DataChannel Open 时间点,单位 ms */ hoWDataChannelOpenAt: number; /** TTFB - Time to First Byte 时间点,单位 ms */ hoWStartTransferAt: number; /** Service Worker 线程收到 resp-head 信息的时间点,单位 ms */ hoWRespMessageAt: number; /** 任务类型:CDN 任务为 `1`,直播任务为 `2` */ taskType: 1 | 2; /** Task ID */ taskID: string; /** 任务对应的业务域名 */ taskDomain: string; /** 缓存匹配完成时间点,单位 ms */ taskCacheMatchAt: number; /** 执行第一个 HTTP do 的时间点,单位 ms */ task1stHttpDoAt: number; /** Result stream 准备好的时间点,单位 ms */ taskResultStreamAt: number; /** Do ID */ doID: string; }; export default class Context { private value; constructor(init?: Context); set(key: K, value: ContextValue[K]): void; get(key: K): ContextValue[K] | undefined; }