Skip to content

docs+ci+refactor: staff-level README, CI/CD, drop global Redis singleton#1

Merged
Chetas-Patil merged 1 commit into
mainfrom
devin/1777718253-staff-readme-and-ci
May 2, 2026
Merged

docs+ci+refactor: staff-level README, CI/CD, drop global Redis singleton#1
Chetas-Patil merged 1 commit into
mainfrom
devin/1777718253-staff-readme-and-ci

Conversation

@devin-ai-integration
Copy link
Copy Markdown

Summary

Replace the one-line README with a staff-level scaffold doc; add CI + security workflows; refactor the code from tutorial-style globals into production patterns.

Documentation (low risk)

  • README rewritten: status banner ("scaffold"), Mermaid target architecture (producers → Redis Streams + consumer groups → workers → DLQ), Mermaid current code-path sequence, configuration, roadmap (XACK/XCLAIM, retries + DLQ, idempotency, OTel/Prom, miniredis/dockertest integration tests), security considerations.

CI / Security (low risk)

  • .github/workflows/ci.yml: vet, lint (golangci-lint-action@v9 + v2.12), build.
  • .github/workflows/security.yml: gosec@v2.26.1, govulncheck on Go stable, aquasecurity/trivy-action@v0.36.0 filesystem SARIF; push/PR + weekly cron.
  • .golangci.yml v2 schema: bodyclose, errcheck, gocritic, govet, ineffassign, misspell, prealloc, revive, staticcheck, unconvert, unused.

Behavior-changing refactor (HIGHER RISK — please review)

  • config.LoadConfig() now returns (*Config, error) with wrapped errors instead of *Config + log.Fatal from inside the loader. Restores the testable contract.
  • internal/app: removed var rdb *redis.Client + sync.Once global. New App{Redis} constructed via app.New(ctx, cfg). The boot-time PING now runs under a 5s context.WithTimeout so a misconfigured Redis fails fast.
  • main.go now uses signal.NotifyContext(SIGINT, SIGTERM) + a run() error pattern so deferred cleanup runs on every exit path (was relying on log.Fatal, which skipped defers).
  • Bumped Redis client from github.com/go-redis/redis v6 (+incompatible, no context support, unmaintained) to github.com/go-redis/redis/v8 (context-aware APIs).

Review & Testing Checklist for Human

  • Run against a local Redis: docker run --rm -p 6379:6379 redis:7-alpine, then go run . from repo root. Expect taskq started; redis=localhost:6379 db=0 followed by clean shutdown on Ctrl-C.
  • Run with bad Redis config (e.g. localhost:6380) — expect a fast failure within ~5 s with a wrapped error like init app: redis ping localhost:6380: .... This validates the new ping timeout.
  • Confirm go-redis v8 bump is acceptable for any downstream code you have locally that imports taskq/internal/app. The exposed type changed from *redis.Client (v6) to *redis.Client (v8) — same name, different package; method signatures gained ctx context.Context as the first arg.
  • Confirm README's roadmap matches your plans for this repo — happy to trim/expand.

Notes

  • The repo's go.mod declares go 1.21.0. CI uses go-version-file: go.mod so the CI runner Go version will track that. We can bump to 1.22+ if you want any of the newer language features.
  • No tests yet. Adding miniredis-backed unit tests (and dockertest for the future producer/worker loops) is on the roadmap.

Link to Devin session: https://app.devin.ai/sessions/475f16f7ca614b56a8f68426fb9485f9
Requested by: @Chetas1

- README: status banner (scaffold), Mermaid target architecture (Redis Streams +
  consumer groups + DLQ), Mermaid current code-path sequence, configuration,
  roadmap (XACK/XCLAIM, retries+DLQ, OTel/Prom, dockertest), security.
- CI: vet/lint/build (golangci-lint-action@v9 + v2.12).
- Security: gosec v2.26.1, govulncheck on Go stable, Trivy 0.36.0 SARIF; cron.
- Refactor (BEHAVIOR-CHANGING — needs review):
  * config.LoadConfig now returns (*Config, error) with wrapped errors instead
    of *Config + log.Fatal in the loader (cleaner test seam).
  * Replaced global 'var rdb *redis.Client' + sync.Once with App{Redis} returned
    from app.New(ctx, cfg). Eliminates global state; tests can construct fresh
    Apps.
  * app.New does a Ping with a 5s ContextTimeout so misconfigured Redis fails
    fast at boot instead of hanging.
  * main.go now uses signal.NotifyContext + run() error pattern; defers fire on
    every exit path (was using log.Fatal which skipped defers).
  * Bumped go-redis from v6 (incompatible / unmaintained) to v8 with
    context-aware APIs.
@devin-ai-integration
Copy link
Copy Markdown
Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@github-advanced-security
Copy link
Copy Markdown

You are seeing this message because GitHub Code Scanning has recently been set up for this repository, or this pull request contains the workflow file for the Code Scanning tool.

What Enabling Code Scanning Means:

  • The 'Security' tab will display more code scanning analysis results (e.g., for the default branch).
  • Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results.
  • You will be able to see the analysis results for the pull request's branch on this overview once the scans have completed and the checks have passed.

For more information about GitHub Code Scanning, check out the documentation.

@Chetas-Patil Chetas-Patil merged commit a20a19e into main May 2, 2026
8 checks passed
Copy link
Copy Markdown
Author

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 1 potential issue.

View 4 additional findings in Devin Review.

Open in Devin Review

Comment thread config/config.go
v.SetConfigName("config")
v.SetConfigType("yaml")
v.AddConfigPath("./config/")
v.AutomaticEnv()
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Missing SetEnvKeyReplacer makes env var overrides for nested config keys silently ineffective

v.AutomaticEnv() is called at config/config.go:33, and the doc comment at line 1-3 explicitly claims environment variables override file values with _ separators (e.g. REDIS_ADDR). However, Viper maps config key redis.addr to env var REDIS.ADDR by default (uppercased with literal .). Without calling v.SetEnvKeyReplacer(strings.NewReplacer(".", "_")), environment variables like REDIS_ADDR, REDIS_PASSWORD, and REDIS_DB will be silently ignored, and the YAML file values will always win. This makes the env override feature broken despite being wired up.

Suggested change
v.AutomaticEnv()
v.AutomaticEnv()
v.SetEnvKeyReplacer(strings.NewReplacer(".", "_"))
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants