Skip to content

Conversation

@capcom6
Copy link
Member

@capcom6 capcom6 commented Dec 4, 2025

Summary by CodeRabbit

  • Chores

    • Upgraded Redis and logger dependencies and added an external caching provider.
    • Disabled the Benchmark job in CI.
  • Breaking Changes

    • Removed in-repo cache implementations, helpers, option APIs, and related tests — callers must migrate to the external cache provider's APIs and types.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Dec 4, 2025

Walkthrough

Replaces the repository's internal caching subsystem with the external github.com/go-core-fx/cachefx: removes local pkg/cache implementations, errors, options, typed helpers, and tests; updates imports and DI wiring; adds cachefx dependency and registers its FX module.

Changes

Cohort / File(s) Summary
Dependency updates
go.mod
Added github.com/go-core-fx/cachefx v0.0.1; bumped github.com/redis/go-redis/v9 and go.uber.org/zap.
Removed core cache implementation & tests
pkg/cache/cache.go, pkg/cache/errors.go, pkg/cache/memory.go, pkg/cache/redis.go, pkg/cache/options.go, pkg/cache/typed.go, pkg/cache/memory_*.go (all memory tests/benches)
Deleted Cache interface, sentinel errors, memory and Redis implementations, options API, typed wrapper, and all related tests/benchmarks.
Removed internal sms-gateway cache artifacts
internal/sms-gateway/cache/config.go, internal/sms-gateway/cache/errors.go, internal/sms-gateway/cache/factory.go
Removed internal Config, ErrInvalidConfig, and factory implementation/types.
Cache DI/module wiring updated
internal/sms-gateway/cache/module.go, internal/config/module.go, internal/sms-gateway/app.go
Switched DI to cachefx: added imports, introduced type Factory = cachefx.Factory alias, adjusted provider signatures to use cachefx.Config, provided a named cachefx.Factory (WithName("sms-gateway")), and registered cachefx.Module() in FX.
Callsites and imports updated
internal/sms-gateway/modules/messages/cache.go, internal/sms-gateway/modules/messages/module.go, internal/sms-gateway/modules/push/service.go, internal/sms-gateway/online/module.go, internal/sms-gateway/online/service.go, internal/sms-gateway/users/cache.go, internal/sms-gateway/users/service.go, internal/sms-gateway/otp/*
Replaced imports from internal pkg/cache to github.com/go-core-fx/cachefx (and .../cache); updated function signatures/parameter types where factory types changed.
Workflow change
.github/workflows/go.yml
Disabled the Benchmark job by adding if: false.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

  • Pay attention to:
    • DI/provider signature and type-alias changes in internal/config/module.go and internal/sms-gateway/cache/module.go.
    • All cache call sites for option/TTL parity (WithTTL, WithValidUntil, AndSetTTL, AndDelete semantics).
    • Removal of public pkg/cache API and tests — ensure no remaining references or external consumers.

Possibly related PRs

Suggested labels

ready

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 14.29% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title '[deps] move cache impl to separate repo' accurately describes the primary change: migrating the internal cache implementation to an external dependency (github.com/go-core-fx/cachefx), removing the pkg/cache package, and updating all internal imports accordingly.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch deps/external-cache-impl

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2b298c9 and 2d37484.

⛔ Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum
📒 Files selected for processing (22)
  • go.mod (2 hunks)
  • internal/config/module.go (2 hunks)
  • internal/sms-gateway/app.go (2 hunks)
  • internal/sms-gateway/cache/config.go (0 hunks)
  • internal/sms-gateway/cache/errors.go (0 hunks)
  • internal/sms-gateway/cache/factory.go (0 hunks)
  • internal/sms-gateway/cache/module.go (1 hunks)
  • internal/sms-gateway/modules/messages/cache.go (1 hunks)
  • internal/sms-gateway/modules/messages/module.go (2 hunks)
  • internal/sms-gateway/modules/push/service.go (3 hunks)
  • internal/sms-gateway/online/module.go (2 hunks)
  • internal/sms-gateway/online/service.go (1 hunks)
  • pkg/cache/cache.go (0 hunks)
  • pkg/cache/errors.go (0 hunks)
  • pkg/cache/memory.go (0 hunks)
  • pkg/cache/memory_bench_test.go (0 hunks)
  • pkg/cache/memory_concurrency_test.go (0 hunks)
  • pkg/cache/memory_edge_test.go (0 hunks)
  • pkg/cache/memory_profile_test.go (0 hunks)
  • pkg/cache/memory_test.go (0 hunks)
  • pkg/cache/options.go (0 hunks)
  • pkg/cache/redis.go (0 hunks)
💤 Files with no reviewable changes (13)
  • internal/sms-gateway/cache/config.go
  • internal/sms-gateway/cache/errors.go
  • pkg/cache/memory_bench_test.go
  • internal/sms-gateway/cache/factory.go
  • pkg/cache/memory_profile_test.go
  • pkg/cache/cache.go
  • pkg/cache/redis.go
  • pkg/cache/errors.go
  • pkg/cache/memory_edge_test.go
  • pkg/cache/memory_test.go
  • pkg/cache/memory_concurrency_test.go
  • pkg/cache/memory.go
  • pkg/cache/options.go
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: capcom6
Repo: android-sms-gateway/server PR: 178
File: pkg/cache/redis.go:63-75
Timestamp: 2025-09-10T23:53:42.006Z
Learning: In pkg/cache/redis.go, the Redis cache implementation uses Redis's native field-level TTL via HExpireAt, meaning expired fields are automatically removed by Redis itself. This differs from the memory implementation where the application tracks expiration times. As a result, operations like Drain that call HGetAll will only return non-expired items since expired fields are already removed by Redis.
Learnt from: capcom6
Repo: android-sms-gateway/server PR: 178
File: pkg/cache/redis.go:63-75
Timestamp: 2025-09-10T23:53:42.006Z
Learning: In pkg/cache/redis.go, the Redis cache implementation uses Redis's native field-level TTL via HExpireAt, meaning expired fields are automatically removed by Redis itself. This differs from the memory implementation where the application tracks expiration times. As a result, operations like Drain that call HGetAll will only return non-expired items since expired fields are already removed by Redis.
📚 Learning: 2025-09-10T23:45:45.502Z
Learnt from: capcom6
Repo: android-sms-gateway/server PR: 178
File: internal/sms-gateway/online/module.go:14-16
Timestamp: 2025-09-10T23:45:45.502Z
Learning: fx.Decorate in uber-go/fx creates module-scoped decorated dependencies, not global modifications. Using fx.Decorate(func(log *zap.Logger) *zap.Logger { return log.Named("module_name") }) is a correct pattern for creating module-specific loggers that are scoped only to that module's dependency graph.

Applied to files:

  • internal/sms-gateway/cache/module.go
  • internal/sms-gateway/online/module.go
🧬 Code graph analysis (6)
internal/config/module.go (1)
internal/config/config.go (1)
  • Config (10-19)
internal/sms-gateway/modules/messages/module.go (2)
internal/sms-gateway/cache/module.go (1)
  • Factory (9-9)
internal/config/config.go (1)
  • Cache (75-77)
internal/sms-gateway/app.go (1)
internal/sms-gateway/cache/module.go (1)
  • Module (11-19)
internal/sms-gateway/cache/module.go (3)
internal/sms-gateway/app.go (1)
  • Module (34-61)
internal/sms-gateway/modules/messages/module.go (1)
  • Module (11-26)
internal/sms-gateway/online/module.go (1)
  • Module (12-37)
internal/sms-gateway/online/module.go (2)
internal/sms-gateway/cache/module.go (1)
  • Factory (9-9)
internal/config/config.go (1)
  • Cache (75-77)
internal/sms-gateway/modules/push/service.go (1)
internal/sms-gateway/cache/module.go (1)
  • Factory (9-9)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
  • GitHub Check: Benchmark
  • GitHub Check: Test
  • GitHub Check: Lint
  • GitHub Check: E2E
  • GitHub Check: Analyze (go)
🔇 Additional comments (11)
internal/sms-gateway/online/module.go (1)

6-7: Clean migration to external cache implementation.

The import alias pattern and factory usage are well-structured. The internal appCache.Factory acts as a wrapper that returns external cache.Cache instances, maintaining a clean separation of concerns.

Also applies to: 18-20

internal/sms-gateway/online/service.go (1)

10-10: LGTM!

Simple import path update with no behavioral changes.

internal/sms-gateway/modules/messages/cache.go (1)

9-9: LGTM!

Import path updated to external cachefx package. The API surface (Cache interface, WithTTL, AndSetTTL helpers) remains unchanged.

internal/sms-gateway/modules/messages/module.go (1)

6-6: Return type updated to external cache implementation.

The fx.Provide return type changed from cacheFactory.Cache (internal) to cacheImpl.Cache (external cachefx). This aligns with the migration and maintains type safety.

Also applies to: 15-17

internal/config/module.go (1)

17-17: Config type migrated to external cachefx.

The configuration provider now returns cachefx.Config instead of the internal cache.Config. The structure appears compatible with the same URL field being used.

Also applies to: 124-128

internal/sms-gateway/cache/module.go (1)

9-9: Factory type alias now publicly exported.

The Factory type is now a public alias of cachefx.Factory, allowing other modules to reference it while maintaining the ability to swap implementations if needed in the future.

go.mod (1)

22-22: Review redis upgrade for breaking changes before merging.

The PR bumps go-redis from v9.9.0 to v9.17.2—a significant upgrade with multiple breaking/behavioral changes that require code review:

  • Typed errors: Error handling changed from string-matching to typed errors (use errors.As/errors.Is instead of string comparisons)
  • Buffer sizes: Default read/write buffers increased from 4KiB to 32KiB (may affect memory; set explicitly if needed)
  • Connection setup: CLIENT SETINFO behavior and timing changed (affects connection identity/DisableIdentity option)
  • Panic to error returns: Several operations now return errors instead of panicking (review error handling for assumptions about panics)
  • New commands and RESP protocol behavior: Verify your server version supports new Redis 8.x commands and RESP protocol expectations match your configuration

The zap v1.27.0→v1.27.1 upgrade is safe (minor patch, no security advisories). However, github.com/go-core-fx/cachefx is a new, unmaintained dependency (0 stars, 1 commit, minimal activity)—consider if an established cache library is preferable.

Run full integration tests, especially for connection pooling and error handling paths.

internal/sms-gateway/app.go (1)

40-43: Module initialization order is correct for Uber fx dependency injection.

The cachefx.Module() declaration before appconfig.Module() does not create a dependency issue. In Uber fx, module declaration order does not determine dependency resolution—fx resolves dependencies by matching parameter types across all registered providers. Since appconfig.Module() provides cachefx.Config (line 124 in internal/config/module.go) and cache.Module() depends on cachefx.Factory from cachefx.Module(), the dependency graph resolves correctly regardless of declaration order. The recent commit moving cache implementation to the external cachefx library (v0.0.0-20251204095227-c346b7da87db) confirms this approach is working without initialization errors.

internal/sms-gateway/modules/push/service.go (3)

8-10: LGTM! Import changes align with external cache migration.

The import structure correctly separates:

  • Internal cache factory wrapper (line 8, aliased as cacheFactory)
  • External cachefx package for cache types and options (line 10)

The aliasing improves code clarity by distinguishing the internal wrapper from the external implementation.


46-46: LGTM! Parameter correctly uses the internal cache factory.

The parameter type cacheFactory.Factory appropriately uses the internal wrapper, which maintains the abstraction layer while leveraging the external cachefx implementation underneath.


210-210: WithTTL usage is correct and consistent with existing patterns.

The cache.WithTTL option is already proven to work elsewhere in the codebase (see internal/sms-gateway/modules/messages/cache.go). The cachefx package properly supports TTL across both memory and Redis backends through its abstracted factory pattern. No further verification needed.

@github-actions
Copy link

github-actions bot commented Dec 4, 2025

🤖 Pull request artifacts

Platform File
🐳 Docker GitHub Container Registry
🍎 Darwin arm64 server_Darwin_arm64.tar.gz
🍎 Darwin x86_64 server_Darwin_x86_64.tar.gz
🐧 Linux arm64 server_Linux_arm64.tar.gz
🐧 Linux i386 server_Linux_i386.tar.gz
🐧 Linux x86_64 server_Linux_x86_64.tar.gz
🪟 Windows arm64 server_Windows_arm64.zip
🪟 Windows i386 server_Windows_i386.zip
🪟 Windows x86_64 server_Windows_x86_64.zip

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
internal/sms-gateway/modules/auth/service.go (1)

13-13: Update cache import to use go-core-fx/cachefx.

The codebase has been migrated to github.com/go-core-fx/cachefx across most modules, but this file still imports the old github.com/capcom6/go-helpers/cache package. The modules modules/auth/ and modules/devices/ have not been updated. Align this import with the rest of the codebase.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2d37484 and a100e6d.

📒 Files selected for processing (4)
  • internal/sms-gateway/modules/auth/passwords.go (1 hunks)
  • internal/sms-gateway/modules/auth/service.go (3 hunks)
  • internal/sms-gateway/modules/messages/service.go (0 hunks)
  • pkg/health/health.go (1 hunks)
💤 Files with no reviewable changes (1)
  • internal/sms-gateway/modules/messages/service.go
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: capcom6
Repo: android-sms-gateway/server PR: 178
File: pkg/cache/redis.go:63-75
Timestamp: 2025-09-10T23:53:42.006Z
Learning: In pkg/cache/redis.go, the Redis cache implementation uses Redis's native field-level TTL via HExpireAt, meaning expired fields are automatically removed by Redis itself. This differs from the memory implementation where the application tracks expiration times. As a result, operations like Drain that call HGetAll will only return non-expired items since expired fields are already removed by Redis.
Learnt from: capcom6
Repo: android-sms-gateway/server PR: 178
File: pkg/cache/redis.go:63-75
Timestamp: 2025-09-10T23:53:42.006Z
Learning: In pkg/cache/redis.go, the Redis cache implementation uses Redis's native field-level TTL via HExpireAt, meaning expired fields are automatically removed by Redis itself. This differs from the memory implementation where the application tracks expiration times. As a result, operations like Drain that call HGetAll will only return non-expired items since expired fields are already removed by Redis.
🧬 Code graph analysis (1)
internal/sms-gateway/modules/auth/service.go (1)
internal/sms-gateway/modules/auth/passwords.go (2)
  • MakeBCryptHash (14-20)
  • CompareBCryptHash (22-27)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: E2E
  • GitHub Check: Benchmark
  • GitHub Check: Analyze (go)
🔇 Additional comments (2)
internal/sms-gateway/modules/auth/passwords.go (1)

1-1: LGTM: Package rename improves cohesion.

Moving bcrypt helpers into the auth package where they're consumed improves module cohesion and eliminates the need for cross-package references.

internal/sms-gateway/modules/auth/service.go (1)

99-99: LGTM: Function calls updated correctly.

All bcrypt helper calls have been consistently updated to reference the local functions after the package rename.

Also applies to: 166-166, 198-198, 202-202

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a100e6d and 938b02c.

📒 Files selected for processing (1)
  • .github/workflows/go.yml (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: capcom6
Repo: android-sms-gateway/server PR: 178
File: pkg/cache/redis.go:63-75
Timestamp: 2025-09-10T23:53:42.006Z
Learning: In pkg/cache/redis.go, the Redis cache implementation uses Redis's native field-level TTL via HExpireAt, meaning expired fields are automatically removed by Redis itself. This differs from the memory implementation where the application tracks expiration times. As a result, operations like Drain that call HGetAll will only return non-expired items since expired fields are already removed by Redis.
Learnt from: capcom6
Repo: android-sms-gateway/server PR: 178
File: pkg/cache/redis.go:63-75
Timestamp: 2025-09-10T23:53:42.006Z
Learning: In pkg/cache/redis.go, the Redis cache implementation uses Redis's native field-level TTL via HExpireAt, meaning expired fields are automatically removed by Redis itself. This differs from the memory implementation where the application tracks expiration times. As a result, operations like Drain that call HGetAll will only return non-expired items since expired fields are already removed by Redis.
🪛 actionlint (1.7.9)
.github/workflows/go.yml

78-78: condition "false" is always evaluated to false. remove the if: section

(if-cond)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: E2E
  • GitHub Check: Lint
  • GitHub Check: Analyze (go)

@capcom6 capcom6 added the ready label Dec 5, 2025
@capcom6 capcom6 force-pushed the deps/external-cache-impl branch from 938b02c to 0c24995 Compare December 5, 2025 23:43
@github-actions github-actions bot removed the ready label Dec 5, 2025
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

♻️ Duplicate comments (1)
.github/workflows/go.yml (1)

75-130: Avoid keeping a permanently disabled benchmark job

if: false makes the entire benchmark job dead code and keeps actionlint complaining. Either remove this job entirely, or replace the condition with something meaningful (e.g., an input flag, label, or schedule) and/or add a short comment explaining when/how it should be re‑enabled.

🧹 Nitpick comments (2)
internal/sms-gateway/modules/push/service.go (1)

8-10: Consider renaming to avoid shadowing the import alias.

The parameter cacheFactory (line 46) shadows the import alias cacheFactory (line 8). While this works correctly—cacheFactory.New(...) calls the method on the Factory instance—it can be confusing to readers.

Consider renaming either the import alias or the parameter for clarity:

-	cacheFactory "github.com/android-sms-gateway/server/internal/sms-gateway/cache"
+	pushCache "github.com/android-sms-gateway/server/internal/sms-gateway/cache"
-	cacheFactory cacheFactory.Factory,
+	cacheFactory pushCache.Factory,

Or alternatively, rename the parameter:

-	cacheFactory cacheFactory.Factory,
+	cf cacheFactory.Factory,

And update usages at lines 50 and 55.

Also applies to: 46-46

internal/config/module.go (1)

124-128: cachefx.Config wiring from app config looks reasonable; verify URL/TTL semantics

Mapping cfg.Cache.URL into cachefx.Config{URL: ...} is straightforward and aligns with the move to cachefx. Please double‑check that:

  • cfg.Cache.URL is in the format that cachefx.Config expects (e.g., Redis DSN, memory URL, etc.).
  • Any previous cache behavior that relied on Redis field‑level TTL and Drain/HGetAll semantics is preserved or explicitly adjusted under cachefx. Based on learnings, the old Redis impl depended on Redis removing expired hash fields automatically before Drain.
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 938b02c and 0c24995.

⛔ Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum
📒 Files selected for processing (27)
  • .github/workflows/go.yml (1 hunks)
  • go.mod (2 hunks)
  • internal/config/module.go (2 hunks)
  • internal/sms-gateway/app.go (2 hunks)
  • internal/sms-gateway/cache/config.go (0 hunks)
  • internal/sms-gateway/cache/errors.go (0 hunks)
  • internal/sms-gateway/cache/factory.go (0 hunks)
  • internal/sms-gateway/cache/module.go (1 hunks)
  • internal/sms-gateway/modules/auth/passwords.go (1 hunks)
  • internal/sms-gateway/modules/auth/service.go (3 hunks)
  • internal/sms-gateway/modules/messages/cache.go (1 hunks)
  • internal/sms-gateway/modules/messages/module.go (2 hunks)
  • internal/sms-gateway/modules/messages/service.go (0 hunks)
  • internal/sms-gateway/modules/push/service.go (3 hunks)
  • internal/sms-gateway/online/module.go (2 hunks)
  • internal/sms-gateway/online/service.go (1 hunks)
  • pkg/cache/cache.go (0 hunks)
  • pkg/cache/errors.go (0 hunks)
  • pkg/cache/memory.go (0 hunks)
  • pkg/cache/memory_bench_test.go (0 hunks)
  • pkg/cache/memory_concurrency_test.go (0 hunks)
  • pkg/cache/memory_edge_test.go (0 hunks)
  • pkg/cache/memory_profile_test.go (0 hunks)
  • pkg/cache/memory_test.go (0 hunks)
  • pkg/cache/options.go (0 hunks)
  • pkg/cache/redis.go (0 hunks)
  • pkg/health/health.go (1 hunks)
💤 Files with no reviewable changes (14)
  • pkg/cache/memory_test.go
  • pkg/cache/memory_bench_test.go
  • internal/sms-gateway/cache/factory.go
  • pkg/cache/memory_profile_test.go
  • pkg/cache/cache.go
  • pkg/cache/memory_edge_test.go
  • internal/sms-gateway/modules/messages/service.go
  • internal/sms-gateway/cache/errors.go
  • pkg/cache/memory_concurrency_test.go
  • pkg/cache/errors.go
  • pkg/cache/memory.go
  • pkg/cache/redis.go
  • pkg/cache/options.go
  • internal/sms-gateway/cache/config.go
🚧 Files skipped from review as they are similar to previous changes (10)
  • internal/sms-gateway/modules/messages/cache.go
  • pkg/health/health.go
  • go.mod
  • internal/sms-gateway/modules/messages/module.go
  • internal/sms-gateway/modules/auth/service.go
  • internal/sms-gateway/modules/auth/passwords.go
  • internal/sms-gateway/cache/module.go
  • internal/sms-gateway/online/service.go
  • internal/sms-gateway/app.go
  • internal/sms-gateway/online/module.go
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: capcom6
Repo: android-sms-gateway/server PR: 178
File: pkg/cache/redis.go:63-75
Timestamp: 2025-09-10T23:53:42.006Z
Learning: In pkg/cache/redis.go, the Redis cache implementation uses Redis's native field-level TTL via HExpireAt, meaning expired fields are automatically removed by Redis itself. This differs from the memory implementation where the application tracks expiration times. As a result, operations like Drain that call HGetAll will only return non-expired items since expired fields are already removed by Redis.
Learnt from: capcom6
Repo: android-sms-gateway/server PR: 178
File: pkg/cache/redis.go:63-75
Timestamp: 2025-09-10T23:53:42.006Z
Learning: In pkg/cache/redis.go, the Redis cache implementation uses Redis's native field-level TTL via HExpireAt, meaning expired fields are automatically removed by Redis itself. This differs from the memory implementation where the application tracks expiration times. As a result, operations like Drain that call HGetAll will only return non-expired items since expired fields are already removed by Redis.
🧬 Code graph analysis (2)
internal/config/module.go (1)
internal/config/config.go (1)
  • Config (10-19)
internal/sms-gateway/modules/push/service.go (1)
internal/sms-gateway/cache/module.go (1)
  • Factory (9-9)
🪛 actionlint (1.7.9)
.github/workflows/go.yml

78-78: condition "false" is always evaluated to false. remove the if: section

(if-cond)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: E2E
  • GitHub Check: Lint
  • GitHub Check: Test
  • GitHub Check: Analyze (go)
🔇 Additional comments (2)
internal/sms-gateway/modules/push/service.go (1)

210-210: LGTM!

The cache.WithTTL option is correctly imported from the external cachefx package, maintaining the same TTL behavior for blacklisted tokens.

internal/config/module.go (1)

17-17: New cachefx dependency import

Importing github.com/go-core-fx/cachefx here matches the PR’s goal of externalizing the cache implementation. Just ensure go.mod/go.sum are updated consistently and that go mod tidy has been run so this import lines up with the resolved version.

@capcom6 capcom6 force-pushed the deps/external-cache-impl branch 2 times, most recently from aec5654 to 034bb76 Compare December 7, 2025 23:30
@capcom6 capcom6 added the ready label Dec 8, 2025
@capcom6 capcom6 force-pushed the deps/external-cache-impl branch from 034bb76 to 8e0618c Compare December 10, 2025 02:47
@github-actions github-actions bot removed the ready label Dec 10, 2025
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

♻️ Duplicate comments (2)
.github/workflows/go.yml (1)

78-78: Duplicate: Benchmark job is permanently disabled.

This issue has already been flagged in a previous review. The job with if: false should either be removed or replaced with a clear explanatory comment.

internal/sms-gateway/cache/module.go (1)

14-14: Duplicate: Logger pattern inconsistency across modules.

This has been flagged previously. The codebase shows inconsistency: some modules use logger.WithNamedLogger("name") (e.g., messages module) while others use fx.Decorate(func(log *zap.Logger) *zap.Logger { return log.Named("name") }) (e.g., online module). Consider standardizing on one pattern for consistency.

🧹 Nitpick comments (1)
internal/sms-gateway/cache/module.go (1)

15-17: Consider aligning factory name with module name.

The factory is named "sms-gateway" via WithName("sms-gateway"), but the fx module is named "cache" (line 13). For consistency and clarity, consider using factory.WithName("cache") unless there's a specific reason for the "sms-gateway" namespace.

Apply this diff if the naming should match the module:

-		fx.Provide(func(factory cachefx.Factory) Factory {
-			return factory.WithName("sms-gateway")
-		}),
+		fx.Provide(func(factory cachefx.Factory) Factory {
+			return factory.WithName("cache")
+		}),
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 034bb76 and 8e0618c.

⛔ Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum
📒 Files selected for processing (25)
  • .github/workflows/go.yml (1 hunks)
  • go.mod (2 hunks)
  • internal/config/module.go (2 hunks)
  • internal/sms-gateway/app.go (2 hunks)
  • internal/sms-gateway/cache/config.go (0 hunks)
  • internal/sms-gateway/cache/errors.go (0 hunks)
  • internal/sms-gateway/cache/factory.go (0 hunks)
  • internal/sms-gateway/cache/module.go (1 hunks)
  • internal/sms-gateway/modules/messages/cache.go (1 hunks)
  • internal/sms-gateway/modules/messages/module.go (2 hunks)
  • internal/sms-gateway/modules/push/service.go (3 hunks)
  • internal/sms-gateway/online/module.go (2 hunks)
  • internal/sms-gateway/online/service.go (1 hunks)
  • internal/sms-gateway/users/cache.go (1 hunks)
  • internal/sms-gateway/users/service.go (1 hunks)
  • pkg/cache/cache.go (0 hunks)
  • pkg/cache/errors.go (0 hunks)
  • pkg/cache/memory.go (0 hunks)
  • pkg/cache/memory_bench_test.go (0 hunks)
  • pkg/cache/memory_concurrency_test.go (0 hunks)
  • pkg/cache/memory_edge_test.go (0 hunks)
  • pkg/cache/memory_profile_test.go (0 hunks)
  • pkg/cache/memory_test.go (0 hunks)
  • pkg/cache/options.go (0 hunks)
  • pkg/cache/redis.go (0 hunks)
💤 Files with no reviewable changes (13)
  • internal/sms-gateway/cache/errors.go
  • pkg/cache/memory_profile_test.go
  • pkg/cache/memory_edge_test.go
  • pkg/cache/memory_bench_test.go
  • pkg/cache/errors.go
  • pkg/cache/memory.go
  • pkg/cache/redis.go
  • internal/sms-gateway/cache/factory.go
  • pkg/cache/options.go
  • internal/sms-gateway/cache/config.go
  • pkg/cache/cache.go
  • pkg/cache/memory_concurrency_test.go
  • pkg/cache/memory_test.go
🚧 Files skipped from review as they are similar to previous changes (8)
  • internal/sms-gateway/modules/push/service.go
  • internal/sms-gateway/online/service.go
  • internal/sms-gateway/modules/messages/cache.go
  • internal/config/module.go
  • internal/sms-gateway/app.go
  • internal/sms-gateway/modules/messages/module.go
  • internal/sms-gateway/online/module.go
  • go.mod
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-09-10T23:45:45.502Z
Learnt from: capcom6
Repo: android-sms-gateway/server PR: 178
File: internal/sms-gateway/online/module.go:14-16
Timestamp: 2025-09-10T23:45:45.502Z
Learning: fx.Decorate in uber-go/fx creates module-scoped decorated dependencies, not global modifications. Using fx.Decorate(func(log *zap.Logger) *zap.Logger { return log.Named("module_name") }) is a correct pattern for creating module-specific loggers that are scoped only to that module's dependency graph.

Applied to files:

  • internal/sms-gateway/cache/module.go
🧬 Code graph analysis (1)
internal/sms-gateway/cache/module.go (3)
internal/sms-gateway/app.go (1)
  • Module (36-65)
internal/sms-gateway/modules/messages/module.go (1)
  • Module (11-26)
internal/sms-gateway/online/module.go (1)
  • Module (12-37)
🪛 actionlint (1.7.9)
.github/workflows/go.yml

78-78: condition "false" is always evaluated to false. remove the if: section

(if-cond)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: Test
  • GitHub Check: Lint
  • GitHub Check: E2E
  • GitHub Check: Analyze (go)
🔇 Additional comments (4)
internal/sms-gateway/users/service.go (1)

8-8: LGTM! Import path updated consistently.

The cache import path has been updated to use the external cachefx library, consistent with the migration in cache.go. The usage of cache.ErrKeyNotFound on line 71 should be covered by the API compatibility verification requested for users/cache.go.

internal/sms-gateway/cache/module.go (2)

4-5: LGTM! Imports aligned with cachefx migration.

The new imports for cachefx and logger are correctly added to support the external cache implementation.


9-9: LGTM! Type alias provides clean module boundary.

The Factory type alias appropriately exposes cachefx.Factory as this module's public API, maintaining clear dependency boundaries with other modules.

internal/sms-gateway/users/cache.go (1)

12-12: API compatibility confirmed - cachefx migration is sound.

The external library github.com/go-core-fx/cachefx/cache provides all required APIs: cache.Typed, cache.NewTyped, cache.AndSetTTL, cache.WithTTL, cache.ErrKeyNotFound, and cache.ErrKeyExpired. The loginCacheWrapper type correctly implements the required Item interface with Marshal() and Unmarshal() methods, making the migration compatible.

@capcom6 capcom6 added the ready label Dec 10, 2025
@capcom6 capcom6 force-pushed the deps/external-cache-impl branch from 8e0618c to dc6c5bc Compare December 12, 2025 23:33
@github-actions github-actions bot removed the ready label Dec 12, 2025
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

♻️ Duplicate comments (1)
.github/workflows/go.yml (1)

75-82: Remove the permanently disabled benchmark job (or document + gate it properly).

if: false at Line 78 makes this job un-runnable; either delete the whole job block, or replace with a real condition (e.g., workflow_dispatch input / label / schedule) and add a brief comment explaining when it should run.

🧹 Nitpick comments (2)
internal/sms-gateway/cache/module.go (1)

15-17: Clarify the factory naming inconsistency.

The module is named "cache" and the logger is named "cache", but the factory is named "sms-gateway". This creates confusion about the purpose and scope of the factory. Consider using factory.WithName("cache") for consistency, or document why "sms-gateway" is the appropriate namespace for this factory.

internal/sms-gateway/online/module.go (1)

15-16: Consider migrating to the logger.WithNamedLogger pattern for consistency.

This module still uses fx.Decorate(func(log *zap.Logger) *zap.Logger { return log.Named("online") }), while other modules in this PR (cache, messages) use logger.WithNamedLogger("online"). Both patterns are functionally equivalent, but consistency across the codebase improves maintainability.

Apply this diff to align with the emerging pattern:

 func Module() fx.Option {
 	return fx.Module(
 		"online",
-		fx.Decorate(func(log *zap.Logger) *zap.Logger {
-			return log.Named("online")
-		}),
+		logger.WithNamedLogger("online"),
 		fx.Provide(func(factory appCache.Factory) (cache.Cache, error) {
 			return factory.New("online")
 		}, fx.Private),
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8e0618c and dc6c5bc.

⛔ Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum
📒 Files selected for processing (26)
  • .github/workflows/go.yml (1 hunks)
  • go.mod (2 hunks)
  • internal/config/module.go (2 hunks)
  • internal/sms-gateway/app.go (2 hunks)
  • internal/sms-gateway/cache/config.go (0 hunks)
  • internal/sms-gateway/cache/errors.go (0 hunks)
  • internal/sms-gateway/cache/factory.go (0 hunks)
  • internal/sms-gateway/cache/module.go (1 hunks)
  • internal/sms-gateway/modules/messages/cache.go (1 hunks)
  • internal/sms-gateway/modules/messages/module.go (2 hunks)
  • internal/sms-gateway/modules/push/service.go (3 hunks)
  • internal/sms-gateway/online/module.go (2 hunks)
  • internal/sms-gateway/online/service.go (1 hunks)
  • internal/sms-gateway/users/cache.go (1 hunks)
  • internal/sms-gateway/users/service.go (1 hunks)
  • pkg/cache/cache.go (0 hunks)
  • pkg/cache/errors.go (0 hunks)
  • pkg/cache/memory.go (0 hunks)
  • pkg/cache/memory_bench_test.go (0 hunks)
  • pkg/cache/memory_concurrency_test.go (0 hunks)
  • pkg/cache/memory_edge_test.go (0 hunks)
  • pkg/cache/memory_profile_test.go (0 hunks)
  • pkg/cache/memory_test.go (0 hunks)
  • pkg/cache/options.go (0 hunks)
  • pkg/cache/redis.go (0 hunks)
  • pkg/cache/typed.go (0 hunks)
💤 Files with no reviewable changes (14)
  • internal/sms-gateway/cache/errors.go
  • pkg/cache/memory_concurrency_test.go
  • pkg/cache/memory_test.go
  • pkg/cache/errors.go
  • pkg/cache/cache.go
  • pkg/cache/redis.go
  • internal/sms-gateway/cache/config.go
  • pkg/cache/options.go
  • pkg/cache/typed.go
  • pkg/cache/memory_bench_test.go
  • pkg/cache/memory.go
  • pkg/cache/memory_edge_test.go
  • pkg/cache/memory_profile_test.go
  • internal/sms-gateway/cache/factory.go
✅ Files skipped from review due to trivial changes (1)
  • internal/sms-gateway/online/service.go
🚧 Files skipped from review as they are similar to previous changes (4)
  • internal/sms-gateway/modules/push/service.go
  • internal/sms-gateway/modules/messages/cache.go
  • internal/sms-gateway/app.go
  • internal/sms-gateway/users/service.go
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-09-10T23:45:45.502Z
Learnt from: capcom6
Repo: android-sms-gateway/server PR: 178
File: internal/sms-gateway/online/module.go:14-16
Timestamp: 2025-09-10T23:45:45.502Z
Learning: fx.Decorate in uber-go/fx creates module-scoped decorated dependencies, not global modifications. Using fx.Decorate(func(log *zap.Logger) *zap.Logger { return log.Named("module_name") }) is a correct pattern for creating module-specific loggers that are scoped only to that module's dependency graph.

Applied to files:

  • internal/sms-gateway/cache/module.go
  • internal/sms-gateway/online/module.go
🧬 Code graph analysis (4)
internal/sms-gateway/cache/module.go (3)
internal/sms-gateway/app.go (1)
  • Module (37-67)
internal/sms-gateway/modules/messages/module.go (1)
  • Module (11-26)
internal/sms-gateway/online/module.go (1)
  • Module (12-37)
internal/sms-gateway/modules/messages/module.go (2)
internal/sms-gateway/cache/module.go (1)
  • Factory (9-9)
internal/config/config.go (1)
  • Cache (79-81)
internal/sms-gateway/online/module.go (2)
internal/sms-gateway/cache/module.go (1)
  • Factory (9-9)
internal/config/config.go (1)
  • Cache (79-81)
internal/config/module.go (2)
internal/config/config.go (1)
  • Config (12-23)
internal/sms-gateway/pubsub/config.go (1)
  • Config (4-7)
🪛 actionlint (1.7.9)
.github/workflows/go.yml

78-78: condition "false" is always evaluated to false. remove the if: section

(if-cond)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Lint
  • GitHub Check: Analyze (go)
🔇 Additional comments (6)
internal/sms-gateway/users/cache.go (1)

12-12: LGTM!

The import path change is straightforward and maintains the same API usage throughout the file.

internal/sms-gateway/modules/messages/module.go (1)

6-6: LGTM!

The provider correctly uses the internal factory to create a cache instance that implements the external cache interface. The pattern aligns with the migration strategy.

Also applies to: 15-17

internal/config/module.go (1)

126-130: LGTM!

The configuration provider correctly migrates to the external cachefx.Config type while maintaining the same configuration structure.

internal/sms-gateway/online/module.go (1)

18-20: LGTM!

The factory provider correctly uses the internal cache factory alias to create a cache instance for the online module.

go.mod (2)

28-28: Zap upgrade to v1.27.1 is safe. The patch version includes only bug fixes: prevention of Object panicking on nils and a race condition fix in WithLazy. No breaking changes are introduced.


24-24: Safe to upgrade; includes critical bug fix in connection pool management.

The upgrade from v9.9.0 to v9.17.2 introduces no breaking changes. v9.17.2 fixes a critical race condition in the connection pool that could cause connection leaks when dial goroutines complete after request timeout, and improves context timeout calculation. No new security vulnerabilities are introduced in this version range.

@capcom6 capcom6 force-pushed the deps/external-cache-impl branch from a31dc1b to de73ae7 Compare December 13, 2025 13:23
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

♻️ Duplicate comments (1)
.github/workflows/go.yml (1)

78-78: Duplicate: Benchmark job permanently disabled.

This concern has already been raised in a previous review comment.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a31dc1b and de73ae7.

⛔ Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum
📒 Files selected for processing (29)
  • .github/workflows/go.yml (1 hunks)
  • go.mod (2 hunks)
  • internal/config/module.go (2 hunks)
  • internal/sms-gateway/app.go (2 hunks)
  • internal/sms-gateway/cache/config.go (0 hunks)
  • internal/sms-gateway/cache/errors.go (0 hunks)
  • internal/sms-gateway/cache/factory.go (0 hunks)
  • internal/sms-gateway/cache/module.go (1 hunks)
  • internal/sms-gateway/modules/messages/cache.go (1 hunks)
  • internal/sms-gateway/modules/messages/module.go (2 hunks)
  • internal/sms-gateway/modules/push/service.go (3 hunks)
  • internal/sms-gateway/online/module.go (2 hunks)
  • internal/sms-gateway/online/service.go (1 hunks)
  • internal/sms-gateway/otp/module.go (2 hunks)
  • internal/sms-gateway/otp/service.go (1 hunks)
  • internal/sms-gateway/otp/storage.go (1 hunks)
  • internal/sms-gateway/users/cache.go (1 hunks)
  • internal/sms-gateway/users/service.go (1 hunks)
  • pkg/cache/cache.go (0 hunks)
  • pkg/cache/errors.go (0 hunks)
  • pkg/cache/memory.go (0 hunks)
  • pkg/cache/memory_bench_test.go (0 hunks)
  • pkg/cache/memory_concurrency_test.go (0 hunks)
  • pkg/cache/memory_edge_test.go (0 hunks)
  • pkg/cache/memory_profile_test.go (0 hunks)
  • pkg/cache/memory_test.go (0 hunks)
  • pkg/cache/options.go (0 hunks)
  • pkg/cache/redis.go (0 hunks)
  • pkg/cache/typed.go (0 hunks)
💤 Files with no reviewable changes (14)
  • pkg/cache/memory_test.go
  • pkg/cache/memory_edge_test.go
  • pkg/cache/memory.go
  • pkg/cache/errors.go
  • pkg/cache/cache.go
  • internal/sms-gateway/cache/errors.go
  • internal/sms-gateway/cache/factory.go
  • pkg/cache/typed.go
  • pkg/cache/redis.go
  • pkg/cache/memory_bench_test.go
  • internal/sms-gateway/cache/config.go
  • pkg/cache/options.go
  • pkg/cache/memory_profile_test.go
  • pkg/cache/memory_concurrency_test.go
🚧 Files skipped from review as they are similar to previous changes (11)
  • internal/sms-gateway/modules/messages/module.go
  • internal/sms-gateway/online/module.go
  • internal/sms-gateway/cache/module.go
  • internal/sms-gateway/online/service.go
  • internal/sms-gateway/app.go
  • internal/sms-gateway/users/service.go
  • internal/config/module.go
  • internal/sms-gateway/users/cache.go
  • go.mod
  • internal/sms-gateway/modules/messages/cache.go
  • internal/sms-gateway/otp/storage.go
🧰 Additional context used
🧬 Code graph analysis (2)
internal/sms-gateway/modules/push/service.go (1)
internal/sms-gateway/cache/module.go (1)
  • Factory (9-9)
internal/sms-gateway/otp/module.go (2)
internal/sms-gateway/cache/module.go (1)
  • Factory (9-9)
internal/config/config.go (1)
  • Cache (79-81)
🪛 actionlint (1.7.9)
.github/workflows/go.yml

78-78: condition "false" is always evaluated to false. remove the if: section

(if-cond)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: E2E
  • GitHub Check: Lint
  • GitHub Check: Analyze (go)
🔇 Additional comments (4)
internal/sms-gateway/modules/push/service.go (2)

8-10: LGTM: Import reorganization supports cache migration.

The import aliasing appropriately distinguishes between the internal factory (cacheFactory) and external cache operations, facilitating the migration to the external library.


43-49: LGTM: Constructor signature updated correctly.

The factory parameter type is correctly updated to use the aliased cacheFactory.Factory, maintaining consistency with the import changes.

internal/sms-gateway/otp/module.go (1)

10-23: LGTM: Module wiring correctly migrated.

The fx module properly integrates with cachefx.Factory, creating a namespaced cache instance via factory.New("otp"). The dependency injection pattern is correctly maintained.

internal/sms-gateway/otp/service.go (1)

10-10: LGTM: Import path updated correctly.

The cache import has been cleanly migrated to the external cachefx library. The usage of cache.WithValidUntil at line 72 remains unchanged, demonstrating API compatibility.

@capcom6 capcom6 added ready deployed The PR is deployed on staging labels Dec 13, 2025
@capcom6 capcom6 merged commit 4392e56 into master Dec 16, 2025
10 checks passed
@capcom6 capcom6 deleted the deps/external-cache-impl branch December 16, 2025 00:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

deployed The PR is deployed on staging ready

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants