testreg

package
v1.11.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 16, 2026 License: GPL-3.0 Imports: 2 Imported by: 0

Documentation

Overview

Package testreg 维护资产「测试连接」操作的可取消上下文注册表。

前端为每次测试生成一个 testID,调用 App 层 Test*Connection(testID, ...) 时通过 Begin 注册一个派生 ctx;用户点击「取消测试」时,前端调用 CancelTest(testID),App 层调用 Cancel(testID) 触发取消。

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Begin

func Begin(parent context.Context, id string) (context.Context, func())

Begin 注册 id → cancel,返回派生 ctx 和 release 函数。 调用方必须 defer release():它会从注册表删除 id 并调用 cancel, 既保证不泄漏 goroutine,又使得 release 后再来的 Cancel(id) 变为 no-op。 空 id 视为不注册(仅返回派生 ctx 与一个只 cancel 的 release)。

func Cancel

func Cancel(id string)

Cancel 触发指定 testID 的取消。未知 id 静默忽略。

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL