Skip to content

[refactor][P3] jetstream fetchWithContext / nextWithContext 近似孪生 #163

Closed

Description

@zy84338719

来源:2026-11-11 全矩阵深度代码审查(6 路并行扫描约 24 万行 Go)。判定已复核;行号基于 2026-11-11 的 main,动手前请核对现场。
归档索引:#161(本仓重构 backlog)

位置

nats/jetstream.go:340-355 vs 359-372

证据

相同的 ctx.Err 预检 + injected := append([]jetstream.FetchOpt{jetstream.FetchContext(ctx)}, opts...) + ErrInvalidOption 回退分支(回退前再查 ctx.Err),仅 Fetch(batchSize)/Next 与错误文案 "fetch cancelled"/"next cancelled" 不同。

建议

抽一个以闭包为执行体的 helper,如 withFetchCtx[T any](ctx, cons, opName string, run func(opts ...jetstream.FetchOpt) (T, error)) (T, error),把注入与回退逻辑单点化;fetch/next 各剩一行调用。

Activity

  1. zy84338719 commented on Nov 12, 2026

    @zy84338719
    ContributorAuthor

    已合入修复 ✅(无 SemVer 发布:本次改动不发版本)

    变更内容

    PR 171 抽泛型 withFetchCtx[T] 收敛 fetchWithContext/nextWithContext 孪生

    合入:PR #171(https://github.com/oekit/network/pull/171),merge commit a1d59855,2026-11-11T19:37:46Z

    CI:link ✅ / Lint & Test / Test ✅ / Lint & Test / Lint ✅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    refactor重构机会(代码审查产出)

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions