Skip to content

feature: support redis config center #7305

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 14 commits into
base: 2.x
Choose a base branch
from
Open

Conversation

YoWuwuuuw
Copy link
Contributor

@YoWuwuuuw YoWuwuuuw commented Apr 21, 2025

  • I have registered the PR changes.

Ⅰ. Describe what this PR did

Ⅱ. Does this pull request fix one issue?

#3617

Ⅲ. Why don't you add test cases (unit test/integration test)?

Ⅳ. Describe how to verify it

Architecture(implement 'AbstractConfiguration')

  1. getLatestConfig(): Configuration read
  2. putConfig(): Write config regardless of whether the configuration already exists
  3. putConfigIfAbsent(): Writes only the configuration that does not exist
  4. removeConfig(): Configuration deletion
  5. addConfigListener() / removeConfigListener(): Listener management

Redis data structure design

  1. Config: use hash structure
    Hash strucrture key: seata: config: SEATA_GROUP
    ConfigKey: dataId
    Value: content
  2. Pub/Sub channel:
    Channel name: seata: config:channel:SEATA_GROUP:dataId
    Message format: {operation}-{dataId}-{content}
    Example: put-server.port-8080

Monitoring mechanism

  1. Inheritance JedisPubSub: Use the native Pub/Sub mechanism of Jedis
  2. Message parsing: Custom message format parsing logic
  3. Condition conversion: Convert Redis messages to Seata configuration change events

ThreadPool

  1. Reason for use: Since the subscribe() of redis is blocking, a thread pool is created to manage subscription, and the number of threads can be configured
  2. Close logic: Use the JVM hook to execute the resource destruction logic for process shutdown

Details

  1. The logic of adding listener: The logic of putting listener into CONFIG_LISTENERS_MAP is placed in the callback method RedisListener.onSubscribe(), and it will only be put in if the subscription is successful
  2. Redis client: The client dependency and jedis initialization logic are aligned with seata-discovery-redis module

Ⅴ. Special notes for reviews

Copy link

codecov bot commented Apr 21, 2025

Codecov Report

Attention: Patch coverage is 74.77064% with 55 lines in your changes missing coverage. Please review.

Project coverage is 58.49%. Comparing base (5cbc488) to head (3a508d5).

Files with missing lines Patch % Lines
.../apache/seata/config/redis/RedisConfiguration.java 74.88% 33 Missing and 20 partials ⚠️
...seata/config/redis/RedisConfigurationProvider.java 0.00% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##                2.x    #7305      +/-   ##
============================================
+ Coverage     58.41%   58.49%   +0.08%     
- Complexity      535      562      +27     
============================================
  Files          1272     1275       +3     
  Lines         45865    46082     +217     
  Branches       5521     5545      +24     
============================================
+ Hits          26791    26956     +165     
- Misses        16552    16586      +34     
- Partials       2522     2540      +18     
Files with missing lines Coverage Δ
.../main/java/org/apache/seata/config/ConfigType.java 100.00% <100.00%> (ø)
...org/apache/seata/config/redis/ConfigOperation.java 100.00% <100.00%> (ø)
...seata/config/redis/RedisConfigurationProvider.java 0.00% <0.00%> (ø)
.../apache/seata/config/redis/RedisConfiguration.java 74.88% <74.88%> (ø)

... and 8 files with indirect coverage changes

Impacted file tree graph

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

1 participant