brokertest

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package brokertest 是 Broker 行为契约的统一验收套件。 memory/sqlite/redis/pg/mysql 五个后端跑同一套 22 条契约用例(见 contracts/broker-contract.md 与 specs/005-identity-replay/contracts/broker-contract-delta.md), 用例只断言语义、不断言实现手段:后端用轮询还是 Cond 唤醒都算合法,只要行为对。 时间一律用 fakeclock 手动推进,禁止真 sleep;唯一的例外是阻塞语义用例里 等 goroutine 结果的短观察窗,并且全部带超时保护。

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(t *testing.T, factory Factory)

Run 对 factory 构造的后端跑全部 22 条契约。这是所有后端的统一验收入口: 后端测试文件里一行 brokertest.Run(t, factory) 即接入。

func RunQuota

func RunQuota(t *testing.T, factory QuotaFactory)

RunQuota 对 factory 构造的后端跑全部配额用例。

Types

type Factory

type Factory func(t *testing.T, opts taskgate.BrokerOptions) taskgate.Broker

Factory 由各后端的测试文件提供:用给定选项构造一个**已 Init**的空 broker。 套件会为每条用例注入独立的 fakeclock 与默认参数(LeaseTTL 60s、LeaseLostMax 3、 ThrottledMax 100),个别用例会按需调小上限(比如 ThrottledMax)。

type QuotaFactory

type QuotaFactory func(t *testing.T, opts taskgate.BrokerOptions) (b taskgate.Broker, advance func(time.Duration))

QuotaFactory 由各后端测试文件提供:构造一个**已 Init**的空 broker(必须实现 QuotaProvider),并返回"把介质时间往前推 d"的回调。opts.Clock 已注入 fakeclock, memory 后端的 advance 就是推它;其他后端推各自的介质时间缝,但**必须同时推 opts.Clock**(调度侧退避走它,两个钟不许漂移)。

Jump to

Keyboard shortcuts

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