Skip to content

Proxy: Modernize internal packages on stdlib and add unit tests. v7.0.145#4667

Merged
winlinvip merged 10 commits into
ossrs:developfrom
winlinvip:develop
Apr 23, 2026
Merged

Proxy: Modernize internal packages on stdlib and add unit tests. v7.0.145#4667
winlinvip merged 10 commits into
ossrs:developfrom
winlinvip:develop

Conversation

@winlinvip
Copy link
Copy Markdown
Member

Modernizes several internal/* packages under the Go proxy, replaces
third-party forks with standard-library primitives, and brings the
test suite from near-zero to high coverage across the touched packages.

Package changes

  • internal/errors — Rewrites the pkg/errors fork as a thin wrapper
    over stdlib errors. A single withStack struct captures stack
    traces via runtime.Callers; fmt.Errorf("%w", ...) handles all
    message wrapping. Restores errors.Is/As/Unwrap chain traversal
    (silently broken in the fork) and deletes ~190 lines of stack/frame
    formatting. Is, As, Unwrap, and Join are re-exported so
    callers need a single import.
  • internal/logger — Swaps stdlib log.Logger for log/slog JSON
    handlers with UTC timestamps and custom level labels (verb, debug,
    warn, error). Hides withContextID (no external callers).
  • internal/sync — Converts Map[K, V] from a concrete struct to
    an interface with a NewMap constructor for testability.
  • internal/signal — Adds signalNotify / osExit indirections so
    InstallSignals and InstallForceQuit can be exercised without real
    OS signals or process termination.
  • internal/utils — Drops deprecated io/ioutil and the stdlib
    errors alias (the internal errors package re-exports what's
    needed).
  • internal/version — No code changes; fully covered by new tests.

winlinvip and others added 9 commits April 19, 2026 18:36
Replaces the pkg/errors fork with a thin wrapper over the standard
library's errors package. A single withStack struct captures stack
traces via runtime.Callers, while fmt.Errorf("%w", ...) handles all
message wrapping. This enables errors.Is/As/Unwrap chain traversal
(the fork silently broke them) and deletes ~190 lines of stack/frame
formatting code. Adds table-driven tests at 100% statement coverage.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Drop the deprecated io/ioutil and the stdlib errors alias — the internal
errors package already re-exports Is, As, Unwrap, and Join, so callers
can keep a single import. Add a utils_test.go covering every exported
helper (API response/error/CORS, ParseBody, BuildStreamURL, peer/closed
network classifiers, URL→stream conversion, RTC/SRT packet sniffers,
ICE/SRT parsers, and ParseListenEndpoint) for 96.3% statement coverage.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Cover all five version helpers (VersionMajor, VersionMinor,
VersionRevision, Version, Signature). The revision assertion checks
that the value is positive rather than pinning an exact number so the
test survives future version bumps.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Introduce signalNotify and osExit indirections so InstallSignals and
InstallForceQuit can be exercised without real OS signal delivery or
process termination. Coverage is 100% in isolation.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Replaces the stdlib log.Logger with log/slog JSON handlers (UTC timestamps,
semantic level labels via custom slog.Level values), hides withContextID
since it has no external callers, and adds unit tests reaching 100%
statement coverage for the package.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Update the internal/env entry to reflect the in-tree .env parser (replacing
godotenv) and the counterfeiter-generated envfakes package. Update the
internal/version entry to use the SRSX signature and align with the SRS
project version, dropping the stale SRSProxy v1.5.0 label.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@winlinvip winlinvip changed the title Proxy: Modernize internal packages on stdlib and add unit tests Proxy: Modernize internal packages on stdlib and add unit tests. v7.0.145 Apr 23, 2026
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@winlinvip winlinvip merged commit 30fc777 into ossrs:develop Apr 23, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant