Skip to content
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

refactor: Remove the StandaloneKafkaConfig struct #4253

Merged
merged 21 commits into from
Jul 12, 2024

Conversation

irenjj
Copy link
Collaborator

@irenjj irenjj commented Jul 2, 2024

I hereby agree to the terms of the GreptimeDB CLA.

Refer to a related PR or issue link (optional)

close: #4159

What's changed and what's your intention?

Remove the StandaloneKafkaConfig struct, and replace StandaloneKafkaConfig with DatanodeKafkaConfig.

Checklist

  • I have written the necessary rustdoc comments.
  • I have added the necessary unit tests and integration tests.
  • This PR requires documentation updates.

Summary by CodeRabbit

  • Refactor

    • Updated configuration struct names and fields for consistency across the application (e.g., StandaloneWalConfig to DatanodeWalConfig).
  • Bug Fixes

    • Corrected typographical errors in configuration files to ensure proper functionality (wal.topic_name_prefix).
  • New Features

    • Added KafkaTopicConfig struct with detailed topic configuration options to enhance Kafka topic management.
  • Documentation

    • Updated references in configuration documentation to reflect new naming conventions for Kafka topic settings.
  • Tests

    • Updated integration tests to use the new KafkaTopicConfig structure for better alignment with configuration changes.

@irenjj irenjj requested a review from a team as a code owner July 2, 2024 12:57
Copy link
Contributor

coderabbitai bot commented Jul 2, 2024

Warning

Rate limit exceeded

@irenjj has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 2 minutes and 37 seconds before requesting another review.

How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

Commits

Files that changed from the base of the PR and between 816176c and accbb58.

Walkthrough

The changes primarily involve renaming the StandaloneKafkaConfig to DatanodeKafkaConfig and consolidating Kafka topic configuration fields into a new struct KafkaTopicConfig. This affects configuration files, test files, and several source files. A typographical error in config/config.md was also noted and should be corrected.

Changes

Files & Paths Change Summary
src/cmd/src/standalone.rs Renamed StandaloneWalConfig to DatanodeWalConfig across struct declarations and usage.
src/common/wal/src/config.rs Removed StandaloneWalConfig, replaced references with DatanodeWalConfig, updated conversion implementations.
src/common/wal/src/config/kafka/common.rs Added KafkaTopicConfig struct and default values.
src/common/wal/src/config/kafka/datanode.rs Added new fields to DatanodeKafkaConfig and modified default implementation.
src/common/wal/src/config/kafka/metasrv.rs Added KafkaTopicConfig to MetasrvKafkaConfig, removed redundant fields.
src/common/meta/src/wal_options_allocator/kafka/topic_manager.rs Updated TopicManager to reference fields within KafkaTopicConfig.
tests-integration/src/tests/test_util.rs Added KafkaTopicConfig, refactored MetasrvWalConfig initialization.
tests-integration/tests/region_migration.rs Introduced KafkaTopicConfig within MetasrvKafkaConfig, refactored initialization.
tests/conf/metasrv-test.toml.template Renamed Kafka topic-related configuration parameters.
config/config.md Noted a typographical error in renaming wal.topic_name_prefix to wal.name_prefix.
config/metasrv.example.toml Renamed and reorganized Kafka topic-related variables.
tests-integration/fixtures/kafka/docker.json New file added with no visible changes.

Sequence Diagram(s)

No sequence diagrams are necessary for these changes as they primarily involve renaming and refactoring configuration structs and fields.

Assessment against linked issues

Objective Addressed Explanation
Remove the StandaloneKafkaConfig struct (#4159)

Poem

In the lands where configs thrive,
Standalone bids goodbye, Datanode arrives.
Kafka topics, now neatly aligned,
With configs redefined.
Cheers to changes, as swift as a breeze,
From the rabbit, a poem to please! 🐇🎵


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions bot added the docs-not-required This change does not impact docs. label Jul 2, 2024
Copy link
Contributor

@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: 2

Outside diff range and nitpick comments (1)
src/common/wal/src/config.rs (1)

Line range hint 191-216: Duplicate deserialization test for DatanodeWalConfig.

The deserialization test for DatanodeWalConfig is duplicated. Remove the redundant test.

-        // Deserialized to DatanodeWalConfig.
-        let standalone_wal_config: DatanodeWalConfig = toml::from_str(toml_str).unwrap();
-        let expected = DatanodeKafkaConfig {
-            broker_endpoints: vec!["127.0.0.1:9092".to_string()],
-            num_topics: 32,
-            selector_type: TopicSelectorType::RoundRobin,
-            topic_name_prefix: "greptimedb_wal_topic".to_string(),
-            num_partitions: 1,
-            replication_factor: 1,
-            create_topic_timeout: Duration::from_secs(30),
-            compression: Compression::default(),
-            max_batch_size: ReadableSize::mb(1),
-            linger: Duration::from_millis(200),
-            consumer_wait_timeout: Duration::from_millis(100),
-            backoff: BackoffConfig {
-                init: Duration::from_millis(500),
-                max: Duration::from_secs(10),
-                base: 2,
-                deadline: Some(Duration::from_secs(60 * 5)),
-            },
-        };
-        assert_eq!(standalone_wal_config, DatanodeWalConfig::Kafka(expected));
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between fd4a928 and e8641ea.

Files selected for processing (5)
  • src/cmd/src/standalone.rs (4 hunks)
  • src/cmd/tests/load_config_test.rs (2 hunks)
  • src/common/wal/src/config.rs (7 hunks)
  • src/common/wal/src/config/kafka.rs (1 hunks)
  • src/common/wal/src/config/kafka/datanode.rs (3 hunks)
Files skipped from review due to trivial changes (1)
  • src/common/wal/src/config/kafka.rs
Additional comments not posted (10)
src/common/wal/src/config/kafka/datanode.rs (3)

22-22: Ensure the TopicSelectorType and constants are correctly defined.

The line imports TopicSelectorType, BROKER_ENDPOINT, and TOPIC_NAME_PREFIX. Verify that these are correctly defined in the respective module.

Verification successful

The TopicSelectorType, BROKER_ENDPOINT, and TOPIC_NAME_PREFIX are correctly defined and imported.

  • TopicSelectorType is defined as an enum in src/common/wal/src/lib.rs.
  • BROKER_ENDPOINT is defined as a constant in src/common/wal/src/lib.rs.
  • TOPIC_NAME_PREFIX is defined as a constant in src/common/wal/src/lib.rs.
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the definition of TopicSelectorType, BROKER_ENDPOINT, and TOPIC_NAME_PREFIX.

# Test: Search for the definitions. Expect: Definitions in the codebase.
rg --type rust $'TopicSelectorType'
rg --type rust $'const BROKER_ENDPOINT'
rg --type rust $'const TOPIC_NAME_PREFIX'

Length of output: 1422


44-56: New fields added to DatanodeKafkaConfig.

Ensure that the new fields (num_topics, num_partitions, selector_type, replication_factor, create_topic_timeout, topic_name_prefix) are correctly integrated and used within the codebase.

Verification successful

New fields added to DatanodeKafkaConfig are correctly integrated and used within the codebase.

The new fields (num_topics, num_partitions, selector_type, replication_factor, create_topic_timeout, topic_name_prefix) are found in various parts of the codebase, indicating proper integration and usage.

Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the usage of new fields in DatanodeKafkaConfig.

# Test: Search for the new fields. Expect: Usage in the codebase.
rg --type rust $'num_topics'
rg --type rust $'num_partitions'
rg --type rust $'selector_type'
rg --type rust $'replication_factor'
rg --type rust $'create_topic_timeout'
rg --type rust $'topic_name_prefix'

Length of output: 12394


71-76: Default values for new fields in DatanodeKafkaConfig.

Ensure that the default values for the new fields (num_topics, num_partitions, selector_type, replication_factor, create_topic_timeout, topic_name_prefix) are appropriate and consistent with the expected configuration.

Verification successful

Default values for new fields in DatanodeKafkaConfig verified.

The default values for the new fields (num_topics, num_partitions, selector_type, replication_factor, create_topic_timeout, topic_name_prefix) are appropriate and consistent with the expected configuration.

  • num_topics: 64
  • num_partitions: 1
  • selector_type: TopicSelectorType::RoundRobin
  • replication_factor: 1
  • create_topic_timeout: Duration::from_secs(30)
  • topic_name_prefix: TOPIC_NAME_PREFIX.to_string()
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the default values of new fields in DatanodeKafkaConfig.

# Test: Search for the default values. Expect: Consistent usage in the codebase.
rg --type rust $'num_topics: 64'
rg --type rust $'num_partitions: 1'
rg --type rust $'selector_type: TopicSelectorType::RoundRobin'
rg --type rust $'replication_factor: 1'
rg --type rust $'create_topic_timeout: Duration::from_secs(30)'
rg --type rust $'topic_name_prefix: TOPIC_NAME_PREFIX.to_string()'

Length of output: 1436



Script:

#!/bin/bash
# Description: Verify the initialization of `replication_factor` and `create_topic_timeout` in the codebase.

# Test: Search for the initialization of `replication_factor` and `create_topic_timeout`. Expect: Consistent usage in the codebase.
rg --type rust 'replication_factor'
rg --type rust 'create_topic_timeout'

Length of output: 2277

src/common/wal/src/config.rs (3)

20-20: Ensure the DatanodeKafkaConfig and MetasrvKafkaConfig imports are correct.

The line imports DatanodeKafkaConfig and MetasrvKafkaConfig. Verify that these are correctly defined in the respective module.

Verification successful

The imports of DatanodeKafkaConfig and MetasrvKafkaConfig are correct.

  • DatanodeKafkaConfig is defined in src/common/wal/src/config/kafka/datanode.rs.
  • MetasrvKafkaConfig is defined in src/common/wal/src/config/kafka/metasrv.rs.
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the definition of DatanodeKafkaConfig and MetasrvKafkaConfig.

# Test: Search for the definitions. Expect: Definitions in the codebase.
rg --type rust $'pub struct DatanodeKafkaConfig'
rg --type rust $'pub struct MetasrvKafkaConfig'

Length of output: 250


Line range hint 46-56: Conversion from DatanodeWalConfig to MetasrvWalConfig.

Ensure that the conversion logic from DatanodeWalConfig to MetasrvWalConfig is correct and handles all fields appropriately.

Verification successful

Verification successful: The conversion logic from DatanodeWalConfig to MetasrvWalConfig handles all fields appropriately.

  • All fields (broker_endpoints, num_topics, selector_type, topic_name_prefix, num_partitions, replication_factor, create_topic_timeout, and backoff) are correctly handled in the conversion.
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the conversion logic from DatanodeWalConfig to MetasrvWalConfig.

# Test: Search for the conversion implementation. Expect: Correct handling of all fields.
rg --type rust $'impl From<DatanodeWalConfig> for MetasrvWalConfig'

Length of output: 149



Script:

#!/bin/bash
# Description: Extract the complete implementation of the `From<DatanodeWalConfig> for MetasrvWalConfig` trait.

# Search for the complete implementation and display surrounding lines for full context.
rg --type rust -A 20 -B 5 'impl From<DatanodeWalConfig> for MetasrvWalConfig'

Length of output: 1798


Line range hint 64-74: Conversion from MetasrvWalConfig to DatanodeWalConfig.

Ensure that the conversion logic from MetasrvWalConfig to DatanodeWalConfig is correct and handles all fields appropriately.

Verification successful

Conversion logic is correct. The conversion from MetasrvWalConfig to DatanodeWalConfig appropriately handles all fields.

  • broker_endpoints
  • num_topics
  • selector_type
  • topic_name_prefix
  • num_partitions
  • replication_factor
  • create_topic_timeout
  • backoff
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the conversion logic from MetasrvWalConfig to DatanodeWalConfig.

# Test: Search for the conversion implementation. Expect: Correct handling of all fields.
rg --type rust $'impl From<MetasrvWalConfig> for DatanodeWalConfig'

Length of output: 149



Script:

#!/bin/bash
# Extract the full implementation of the From trait for MetasrvWalConfig to DatanodeWalConfig
ast-grep --lang rust --pattern $'impl From<MetasrvWalConfig> for DatanodeWalConfig {
  fn from(config: MetasrvWalConfig) -> Self {
    match config {
      MetasrvWalConfig::RaftEngine => $_,
      MetasrvWalConfig::Kafka($_) => $_,
      $$$
    }
  }
}'

Length of output: 256



Script:

#!/bin/bash
# Extract the implementation of the From trait for MetasrvWalConfig to DatanodeWalConfig and surrounding lines for context
rg --type rust --context 10 'impl From<MetasrvWalConfig> for DatanodeWalConfig'

Length of output: 1645

src/cmd/tests/load_config_test.rs (1)

23-23: Ensure the DatanodeWalConfig import is correct.

The line imports DatanodeWalConfig. Verify that it is correctly defined in the respective module.

src/cmd/src/standalone.rs (3)

42-42: Ensure the DatanodeWalConfig import is correct.

The line imports DatanodeWalConfig. Verify that it is correctly defined in the respective module.

Verification successful

The DatanodeWalConfig import is correct.

The DatanodeWalConfig is defined in src/common/wal/src/config.rs, confirming the correctness of the import statement in src/cmd/src/standalone.rs.

  • src/common/wal/src/config.rs: pub enum DatanodeWalConfig {
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the definition of DatanodeWalConfig.

# Test: Search for the definition. Expect: Definition in the codebase.
rg --type rust $'pub enum DatanodeWalConfig'

Length of output: 103


129-129: Ensure the wal field in StandaloneOptions is correctly integrated.

The line adds the wal field to StandaloneOptions. Verify that it is correctly integrated and used within the codebase.


154-154: Ensure the default value for the wal field in StandaloneOptions is correct.

The line sets the default value for the wal field in StandaloneOptions. Verify that the default value is appropriate and consistent with the expected configuration.

Verification successful

The default value for the wal field in StandaloneOptions is appropriate.

The wal field is set to DatanodeWalConfig::default(), which defaults to DatanodeWalConfig::RaftEngine(RaftEngineConfig::default()). The default values for RaftEngineConfig include reasonable settings such as a file size of 256 MB, a purge threshold of 4 GB, and other typical configurations for a Raft engine.

  • src/common/wal/src/config.rs
  • src/common/wal/src/config/raft_engine.rs
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the default value of the wal field in StandaloneOptions.

# Test: Search for the default value of the wal field. Expect: Consistent usage in the codebase.
rg --type rust $'wal: DatanodeWalConfig::default()'

Length of output: 282



Script:

#!/bin/bash
# Locate the implementation of DatanodeWalConfig::default() to inspect the default values.
ast-grep --lang rust --pattern 'impl DatanodeWalConfig {
    fn default() -> Self {
        $_
    }
}'

Length of output: 105



Script:

#!/bin/bash
# Locate the definition of the DatanodeWalConfig struct
rg --type rust 'struct DatanodeWalConfig'

# Once we have the file, locate the implementation of the default method for DatanodeWalConfig within the same file
rg --type rust 'impl DatanodeWalConfig' -A 10

Length of output: 91



Script:

#!/bin/bash
# Search for the keyword 'DatanodeWalConfig' in the entire repository to locate its definition and related implementations.
rg 'DatanodeWalConfig'

Length of output: 5970



Script:

#!/bin/bash
# Search for the impl Default for DatanodeWalConfig block in src/common/wal/src/config.rs to inspect the default values.
rg 'impl Default for DatanodeWalConfig' -A 10 src/common/wal/src/config.rs

Length of output: 474



Script:

#!/bin/bash
# Search for the impl Default for RaftEngineConfig block to inspect the default values.
rg 'impl Default for RaftEngineConfig' -A 10

Length of output: 889

src/common/wal/src/config/kafka/datanode.rs Outdated Show resolved Hide resolved
src/cmd/src/standalone.rs Show resolved Hide resolved
Copy link
Contributor

@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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between e8641ea and 3bce938.

Files selected for processing (2)
  • src/common/wal/src/config.rs (7 hunks)
  • src/common/wal/src/config/kafka/datanode.rs (3 hunks)
Files skipped from review as they are similar to previous changes (2)
  • src/common/wal/src/config.rs
  • src/common/wal/src/config/kafka/datanode.rs

Copy link
Contributor

@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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 3bce938 and 8abd3a2.

Files selected for processing (4)
  • src/cmd/src/standalone.rs (4 hunks)
  • src/cmd/tests/load_config_test.rs (2 hunks)
  • src/common/wal/src/config.rs (7 hunks)
  • src/common/wal/src/config/kafka/datanode.rs (2 hunks)
Files skipped from review as they are similar to previous changes (4)
  • src/cmd/src/standalone.rs
  • src/cmd/tests/load_config_test.rs
  • src/common/wal/src/config.rs
  • src/common/wal/src/config/kafka/datanode.rs

Copy link

codecov bot commented Jul 2, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 84.90%. Comparing base (da0c840) to head (accbb58).
Report is 6 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4253      +/-   ##
==========================================
- Coverage   85.18%   84.90%   -0.29%     
==========================================
  Files        1060     1059       -1     
  Lines      189069   189033      -36     
==========================================
- Hits       161057   160493     -564     
- Misses      28012    28540     +528     

Copy link
Contributor

@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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 8abd3a2 and 75dbad4.

Files selected for processing (1)
  • src/common/wal/src/config/kafka/datanode.rs (3 hunks)
Files skipped from review as they are similar to previous changes (1)
  • src/common/wal/src/config/kafka/datanode.rs

Copy link
Contributor

@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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 75dbad4 and 8e62a4f.

Files selected for processing (5)
  • src/common/meta/src/wal_options_allocator/kafka/topic_manager.rs (5 hunks)
  • src/common/wal/src/config.rs (5 hunks)
  • src/common/wal/src/config/kafka/common.rs (2 hunks)
  • src/common/wal/src/config/kafka/datanode.rs (3 hunks)
  • src/common/wal/src/config/kafka/metasrv.rs (2 hunks)
Additional comments not posted (18)
src/common/wal/src/config/kafka/metasrv.rs (3)

19-19: LGTM! The import statement is necessary.

The addition of KafkaTopicConfig, backoff_prefix, and BackoffConfig is appropriate to support the new configuration structure.


31-31: LGTM! The addition of the kafka_topic field improves modularity.

The kafka_topic field of type KafkaTopicConfig consolidates topic-related configurations into a single struct.


38-49: LGTM! The Default implementation correctly initializes the new field.

The Default implementation for MetasrvKafkaConfig correctly initializes the kafka_topic field with appropriate default values.

src/common/wal/src/config/kafka/datanode.rs (3)

21-21: LGTM! The import statement is necessary.

The addition of KafkaTopicConfig, backoff_prefix, and BackoffConfig is appropriate to support the new configuration structure.


43-45: LGTM! The addition of the kafka_topic field improves modularity.

The kafka_topic field of type KafkaTopicConfig consolidates topic-related configurations into a single struct.


57-57: LGTM! The Default implementation correctly initializes the new field.

The Default implementation for DatanodeKafkaConfig correctly initializes the kafka_topic field with appropriate default values.

src/common/wal/src/config/kafka/common.rs (3)

20-21: LGTM! The import statement is necessary.

The addition of TopicSelectorType and TOPIC_NAME_PREFIX is appropriate to support the new configuration structure.


52-68: LGTM! The addition of KafkaTopicConfig improves modularity.

The KafkaTopicConfig struct encapsulates topic-related configurations, improving modularity and readability.


70-81: LGTM! The Default implementation correctly initializes the fields.

The Default implementation for KafkaTopicConfig correctly initializes the fields with appropriate default values.

src/common/wal/src/config.rs (4)

20-20: LGTM! The import statement is necessary.

The addition of DatanodeKafkaConfig and MetasrvKafkaConfig is appropriate to support the new configuration structure.


46-53: LGTM! The From implementation correctly maps the fields.

The From implementation for DatanodeWalConfig to MetasrvWalConfig correctly maps the fields, including the new kafka_topic field.


59-66: LGTM! The From implementation correctly maps the fields.

The From implementation for MetasrvWalConfig to DatanodeWalConfig correctly maps the fields, including the new kafka_topic field.


Line range hint 82-187: LGTM! The test cases correctly reflect the changes.

The test cases have been updated to reflect the new configuration structure, ensuring proper testing of the new mappings.

src/common/meta/src/wal_options_allocator/kafka/topic_manager.rs (5)

59-60: LGTM! The initialization consolidates topic-related configurations.

The initialization of the topics vector using the kafka_topic field improves readability and maintainability.


63-63: LGTM! The initialization consolidates topic-related configurations.

The initialization of the selector using the selector_type field from kafka_topic improves readability and maintainability.


79-79: LGTM! The usage consolidates topic-related configurations.

The usage of the num_topics field from kafka_topic in the start method improves readability and maintainability.


188-190: LGTM! The usage consolidates topic-related configurations.

The usage of fields from kafka_topic in the try_create_topic method improves readability and maintainability.


Line range hint 245-293: LGTM! The test case correctly reflects the changes.

The test case has been updated to reflect the new configuration structure, ensuring proper testing of the new mappings.

Copy link
Contributor

@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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 8e62a4f and f6403a7.

Files selected for processing (1)
  • src/common/wal/src/config.rs (4 hunks)
Additional comments not posted (5)
src/common/wal/src/config.rs (5)

20-20: Approved: Updated import statement.

The import statement has been updated correctly to remove StandaloneKafkaConfig.


46-53: Approved: Implementation of From trait for DatanodeWalConfig to MetasrvWalConfig.

The conversion logic correctly maps the relevant fields from DatanodeKafkaConfig to MetasrvKafkaConfig.


59-66: Approved: Implementation of From trait for MetasrvWalConfig to DatanodeWalConfig.

The conversion logic correctly maps the relevant fields from MetasrvKafkaConfig to DatanodeKafkaConfig.


79-79: Approved: Added import statement for KafkaTopicConfig.

The import statement is necessary for the test cases that involve KafkaTopicConfig.


159-166: Approved: Updated test cases for MetasrvKafkaConfig and DatanodeKafkaConfig.

The test cases have been updated to correctly reflect the new structure, including the kafka_topic field.

Also applies to: 183-192

Copy link
Contributor

@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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between f6403a7 and 286382f.

Files selected for processing (1)
  • src/common/meta/src/wal_options_allocator.rs (2 hunks)
Additional comments not posted (3)
src/common/meta/src/wal_options_allocator.rs (3)

126-126: Import statements are correct.

The import of KafkaTopicConfig is necessary for the test cases.


164-167: Initialize KafkaTopicConfig with required fields.

Ensure that all required fields for KafkaTopicConfig are initialized.

Are there any required fields that are missing in this initialization?


168-170: Configuration initialization is correct.

The MetasrvKafkaConfig is correctly initialized with the kafka_topic field.

Copy link
Contributor

@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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 286382f and d39c0d9.

Files selected for processing (2)
  • tests-integration/src/tests/test_util.rs (3 hunks)
  • tests-integration/tests/region_migration.rs (8 hunks)
Additional comments not posted (7)
tests-integration/src/tests/test_util.rs (2)

235-239: Verify the correctness of the KafkaTopicConfig initialization.

The new KafkaTopicConfig is correctly initialized with topic_name_prefix, num_topics, and default values for other fields. Ensure that these configurations are correct and complete.


268-272: Verify the correctness of the KafkaTopicConfig initialization.

The new KafkaTopicConfig is correctly initialized with topic_name_prefix, num_topics, and default values for other fields. Ensure that these configurations are correct and complete.

tests-integration/tests/region_migration.rs (5)

122-126: Verify the correctness of the KafkaTopicConfig initialization.

The new KafkaTopicConfig is correctly initialized with num_topics, topic_name_prefix, and default values for other fields. Ensure that these configurations are correct and complete.


254-258: Verify the correctness of the KafkaTopicConfig initialization.

The new KafkaTopicConfig is correctly initialized with num_topics, topic_name_prefix, and default values for other fields. Ensure that these configurations are correct and complete.


379-383: Verify the correctness of the KafkaTopicConfig initialization.

The new KafkaTopicConfig is correctly initialized with num_topics, topic_name_prefix, and default values for other fields. Ensure that these configurations are correct and complete.


503-507: Verify the correctness of the KafkaTopicConfig initialization.

The new KafkaTopicConfig is correctly initialized with num_topics, topic_name_prefix, and default values for other fields. Ensure that these configurations are correct and complete.


642-646: Verify the correctness of the KafkaTopicConfig initialization.

The new KafkaTopicConfig is correctly initialized with num_topics, topic_name_prefix, and default values for other fields. Ensure that these configurations are correct and complete.

Copy link
Contributor

@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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between d39c0d9 and cbcf0af.

Files selected for processing (9)
  • config/config.md (1 hunks)
  • config/metasrv.example.toml (1 hunks)
  • src/common/meta/src/wal_options_allocator/kafka/topic_manager.rs (5 hunks)
  • src/common/wal/src/config.rs (4 hunks)
  • src/common/wal/src/config/kafka/common.rs (2 hunks)
  • src/common/wal/src/config/kafka/datanode.rs (3 hunks)
  • src/common/wal/src/config/kafka/metasrv.rs (2 hunks)
  • tests-integration/src/tests/test_util.rs (3 hunks)
  • tests-integration/tests/region_migration.rs (8 hunks)
Files skipped from review due to trivial changes (1)
  • config/config.md
Files skipped from review as they are similar to previous changes (6)
  • src/common/meta/src/wal_options_allocator/kafka/topic_manager.rs
  • src/common/wal/src/config/kafka/common.rs
  • src/common/wal/src/config/kafka/datanode.rs
  • src/common/wal/src/config/kafka/metasrv.rs
  • tests-integration/src/tests/test_util.rs
  • tests-integration/tests/region_migration.rs
Additional comments not posted (12)
config/metasrv.example.toml (5)

80-80: LGTM!

The renaming of num_topics to kafka_topic_num_topics is consistent with the new configuration structure.


85-85: LGTM!

The renaming of selector_type to kafka_topic_selector_type is consistent with the new configuration structure.


88-88: LGTM!

The renaming of topic_name_prefix to kafka_topic_name_prefix is consistent with the new configuration structure.


91-91: LGTM!

The renaming of replication_factor to kafka_topic_replication_factor is consistent with the new configuration structure.


94-94: LGTM!

The renaming of create_topic_timeout to kafka_topic_create_topic_timeout is consistent with the new configuration structure.

src/common/wal/src/config.rs (7)

20-20: LGTM!

The import statement has been updated to include DatanodeKafkaConfig and MetasrvKafkaConfig, consistent with the new configuration structure.


46-53: LGTM!

The implementation of From<DatanodeWalConfig> for MetasrvWalConfig has been updated to handle DatanodeWalConfig instead of StandaloneWalConfig, consistent with the new configuration structure.


59-66: LGTM!

The implementation of From<MetasrvWalConfig> for DatanodeWalConfig has been updated to handle MetasrvWalConfig instead of StandaloneWalConfig, consistent with the new configuration structure.


142-147: LGTM!

The test_toml_kafka test case has been updated to reflect the new configuration structure, consistent with the renaming of configuration fields.


160-167: LGTM!

The KafkaTopicConfig struct in the test_toml_kafka test case has been updated to reflect the new configuration structure, consistent with the renaming of configuration fields.


184-190: LGTM!

The KafkaTopicConfig struct in the test_toml_kafka test case has been updated to reflect the new configuration structure for DatanodeWalConfig, consistent with the renaming of configuration fields.


193-193: LGTM!

The assertion for DatanodeWalConfig in the test_toml_kafka test case has been updated to reflect the new configuration structure, consistent with the renaming of configuration fields.

Copy link
Contributor

@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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between cbcf0af and d2fefab.

Files selected for processing (2)
  • config/config.md (1 hunks)
  • tests/conf/metasrv-test.toml.template (1 hunks)
Files skipped from review due to trivial changes (1)
  • tests/conf/metasrv-test.toml.template
Files skipped from review as they are similar to previous changes (1)
  • config/config.md

@evenyag evenyag requested a review from WenyXu July 4, 2024 06:41
config/metasrv.example.toml Outdated Show resolved Hide resolved
Copy link
Contributor

@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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between d2fefab and 3481f13.

Files selected for processing (1)
  • tests/conf/metasrv-test.toml.template (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • tests/conf/metasrv-test.toml.template

Copy link
Contributor

@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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 3481f13 and def0922.

Files selected for processing (2)
  • src/common/wal/src/config/kafka/common.rs (2 hunks)
  • src/common/wal/src/config/kafka/metasrv.rs (1 hunks)
Files skipped from review as they are similar to previous changes (2)
  • src/common/wal/src/config/kafka/common.rs
  • src/common/wal/src/config/kafka/metasrv.rs

Copy link
Contributor

@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

Commits

Files that changed from the base of the PR and between def0922 and 307c20e.

Files selected for processing (6)
  • config/config.md (1 hunks)
  • src/cmd/src/standalone.rs (4 hunks)
  • src/common/meta/src/wal_options_allocator/kafka/topic_manager.rs (5 hunks)
  • src/common/wal/src/config.rs (4 hunks)
  • src/common/wal/src/config/kafka/datanode.rs (3 hunks)
  • tests-integration/fixtures/kafka/docker.json (1 hunks)
Files skipped from review due to trivial changes (1)
  • src/common/meta/src/wal_options_allocator/kafka/topic_manager.rs
Files skipped from review as they are similar to previous changes (4)
  • config/config.md
  • src/cmd/src/standalone.rs
  • src/common/wal/src/config.rs
  • src/common/wal/src/config/kafka/datanode.rs
Additional context used
Biome
tests-integration/fixtures/kafka/docker.json

[error] 1-1: Expected an array, an object, or a literal but instead found the end of the file.

Expected an array, an object, or a literal here.

(parse)

tests-integration/fixtures/kafka/docker.json Outdated Show resolved Hide resolved
@irenjj irenjj requested a review from WenyXu July 7, 2024 02:38
@killme2008
Copy link
Contributor

@WenyXu @fengjiachun Please take a look.

src/common/wal/src/config/kafka/metasrv.rs Outdated Show resolved Hide resolved
config/metasrv.example.toml Outdated Show resolved Hide resolved
Copy link
Contributor

@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

Commits

Files that changed from the base of the PR and between 307c20e and 51fa276.

Files selected for processing (9)
  • config/config.md (1 hunks)
  • config/metasrv.example.toml (1 hunks)
  • src/cmd/src/standalone.rs (4 hunks)
  • src/common/meta/src/wal_options_allocator/kafka/topic_manager.rs (5 hunks)
  • src/common/wal/src/config.rs (4 hunks)
  • src/common/wal/src/config/kafka/common.rs (2 hunks)
  • src/common/wal/src/config/kafka/datanode.rs (3 hunks)
  • src/common/wal/src/config/kafka/metasrv.rs (1 hunks)
  • tests/conf/metasrv-test.toml.template (1 hunks)
Files skipped from review as they are similar to previous changes (7)
  • config/metasrv.example.toml
  • src/common/meta/src/wal_options_allocator/kafka/topic_manager.rs
  • src/common/wal/src/config.rs
  • src/common/wal/src/config/kafka/common.rs
  • src/common/wal/src/config/kafka/datanode.rs
  • src/common/wal/src/config/kafka/metasrv.rs
  • tests/conf/metasrv-test.toml.template
Additional context used
GitHub Check: Check typos and docs
config/config.md

[warning] 284-284:
"anme" should be "name" or "anime".

GitHub Check: Spell Check with Typos
config/config.md

[warning] 284-284:
"anme" should be "name" or "anime".

Additional comments not posted (4)
src/cmd/src/standalone.rs (4)

43-43: Import change approved.

The import of DatanodeWalConfig aligns with the PR objective of replacing StandaloneWalConfig.


133-133: Struct field change approved.

The change from StandaloneWalConfig to DatanodeWalConfig aligns with the PR objective.


158-158: Default implementation change approved.

The change from StandaloneWalConfig::default() to DatanodeWalConfig::default() aligns with the PR objective.


207-207: Usage change approved but requires verification.

The change from StandaloneWalConfig to DatanodeWalConfig is approved. However, ensure that all references to wal are correctly integrated and used within the codebase.
[approved, verify]

#!/bin/bash
# Description: Verify the usage of the wal field in datanode_options.

# Test: Search for the usage of the wal field. Expect: Correct integration in the codebase.
rg --type rust $'wal: cloned_opts.wal'

config/config.md Outdated Show resolved Hide resolved
Copy link
Contributor

@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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 51fa276 and 816176c.

Files selected for processing (1)
  • config/config.md (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • config/config.md

@irenjj
Copy link
Collaborator Author

irenjj commented Jul 10, 2024

PTAL @WenyXu @fengjiachun

Copy link
Member

@WenyXu WenyXu left a comment

Choose a reason for hiding this comment

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

Thanks!

Copy link
Collaborator

@fengjiachun fengjiachun left a comment

Choose a reason for hiding this comment

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

LGTM

@fengjiachun
Copy link
Collaborator

@irenjj Thanks!

@fengjiachun fengjiachun added this pull request to the merge queue Jul 12, 2024
Merged via the queue into GreptimeTeam:main with commit 9f2d53c Jul 12, 2024
53 checks passed
@irenjj irenjj deleted the remove_redundant_kafka_config branch July 12, 2024 11:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs-not-required This change does not impact docs.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove the StandaloneKafkaConfig struct
4 participants