Skip to content

Conversation

@Mat001
Copy link
Contributor

@Mat001 Mat001 commented Nov 10, 2025

This commit integrates Redis Streams for persistent notification delivery from v4.3.0-beta.1 with the existing CMAB Redis cache support in master.

Features Added:

  • Redis Streams implementation for notification synchronization with persistent message delivery, automatic retries, consumer groups, and configurable batching
  • Flexible Redis authentication utility supporting auth_token, redis_secret, and password fields with environment variable fallback
  • Applied flexible auth pattern to all Redis clients: ODP cache, UPS, CMAB cache, and synchronization pubsub
  • Configurable CMAB prediction endpoint via config or environment variable

Changes:

  • Added pkg/syncer/pubsub/redis_streams.go and comprehensive tests
  • Added pkg/utils/redisauth for flexible password authentication
  • Updated all Redis clients (ODP, UPS, CMAB) with UnmarshalJSON for auth
  • Updated config.yaml with Redis Streams parameters and auth_token field
  • Updated CHANGELOG.md with [Unreleased] section documenting new features
  • Updated CI workflow to use Redis 6 and added Redis to test-coverage job
  • Added docs/redis-streams.md with complete Redis Streams documentation

Configuration:

  • CMAB configuration remains under client.cmab section
  • Redis Streams enabled via synchronization.notification.default
  • All Redis clients support auth_token, redis_secret, password fields
  • Environment variables: REDIS_PASSWORD, REDIS_ODP_PASSWORD, REDIS_UPS_PASSWORD, REDIS_CMAB_PASSWORD

Testing:

  • All existing tests pass
  • Added 5 new auth tests for CMAB Redis cache
  • Redis Streams includes 18 comprehensive tests
  • redisauth utility includes 14 tests covering all scenarios

Both features coexist without conflicts - Redis Streams uses STREAM data type for messaging while CMAB cache uses STRING type for key-value storage.

Issues

This commit integrates Redis Streams for persistent notification delivery
from v4.3.0-beta.1 with the existing CMAB Redis cache support in master.

Features Added:
- Redis Streams implementation for notification synchronization with
  persistent message delivery, automatic retries, consumer groups, and
  configurable batching
- Flexible Redis authentication utility supporting auth_token, redis_secret,
  and password fields with environment variable fallback
- Applied flexible auth pattern to all Redis clients: ODP cache, UPS,
  CMAB cache, and synchronization pubsub
- Configurable CMAB prediction endpoint via config or environment variable

Changes:
- Added pkg/syncer/pubsub/redis_streams.go and comprehensive tests
- Added pkg/utils/redisauth for flexible password authentication
- Updated all Redis clients (ODP, UPS, CMAB) with UnmarshalJSON for auth
- Updated config.yaml with Redis Streams parameters and auth_token field
- Updated CHANGELOG.md with [Unreleased] section documenting new features
- Updated CI workflow to use Redis 6 and added Redis to test-coverage job
- Added docs/redis-streams.md with complete Redis Streams documentation

Configuration:
- CMAB configuration remains under client.cmab section
- Redis Streams enabled via synchronization.notification.default
- All Redis clients support auth_token, redis_secret, password fields
- Environment variables: REDIS_PASSWORD, REDIS_ODP_PASSWORD,
  REDIS_UPS_PASSWORD, REDIS_CMAB_PASSWORD

Testing:
- All existing tests pass
- Added 5 new auth tests for CMAB Redis cache
- Redis Streams includes 18 comprehensive tests
- redisauth utility includes 14 tests covering all scenarios

Both features coexist without conflicts - Redis Streams uses STREAM data
type for messaging while CMAB cache uses STRING type for key-value storage.
@Mat001 Mat001 self-assigned this Nov 10, 2025
@Mat001 Mat001 requested a review from jaeopt November 12, 2025 23:05
Copy link
Contributor

@jaeopt jaeopt left a comment

Choose a reason for hiding this comment

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

Looks great! A few suggestions to be considered.

enable: true
## Use "redis" for fire-and-forget pub/sub (existing behavior)
## Use "redis-streams" for persistent message delivery with retries and acknowledgment
default: "redis-streams"
Copy link
Contributor

@jaeopt jaeopt Nov 14, 2025

Choose a reason for hiding this comment

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

Do clients need any changes for redis vs redis-streams?
Clients with redis notifications can switch to redis-streams without any change in the client server?

Copy link
Contributor

Choose a reason for hiding this comment

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

What is downside of redis-streams? Wondering if we can support redis-streams only (batch=1 same as the current redis option?)

}

// First, unmarshal normally to get all fields
if err := json.Unmarshal(data, alias); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

I do not see alias used any where. Can't it be removed? Wondering if you have other reason for this.

}

// First, unmarshal normally to get all fields
if err := json.Unmarshal(data, alias); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

same here for alias?

Copy link
Contributor

@jaeopt jaeopt Nov 14, 2025

Choose a reason for hiding this comment

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

wondering if this logic (UnmarshalJSON) can be shared for all redis clients?


const (
SyncFeatureFlagNotificaiton SycnFeatureFlag = "sync-feature-flag-notification"
SycnFeatureFlagDatafile SycnFeatureFlag = "sync-feature-flag-datafile"
Copy link
Contributor

Choose a reason for hiding this comment

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

Interesting - consistently misspelled all of them :)

## Use "redis" for fire-and-forget pub/sub (existing behavior)
## Use "redis-streams" for persistent message delivery with retries and acknowledgment
default: "redis"
# default: "redis-streams" # Uncomment to enable Redis Streams
Copy link
Contributor

@jaeopt jaeopt Nov 14, 2025

Choose a reason for hiding this comment

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

datafile sync is agent-internal. Do we need to care about this redis-streams option?
I see a value, but it may be confusing to the clients.

Comment on lines +63 to +64
} else if conf.Datafile.Default == PubSubRedisStreams {
return getPubSubRedisStreams(conf)
Copy link
Contributor

Choose a reason for hiding this comment

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

Same, this is agent-internal. Less value compared to the confusion? We can consider focusing on notification sync only for redis-stream support.

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.

3 participants