shardingsphere icon indicating copy to clipboard operation
shardingsphere copied to clipboard

Confusion about the positioning of ShardingRuleConfiguration

Open linghengqian opened this issue 3 years ago • 5 comments

Question

For English only, other languages will not accept.

Before asking a question, make sure you have:

Please pay attention on issues you submitted, because we maybe need more details. If no response anymore and we cannot reproduce it on current information, we will close it

  • I took a look at https://shardingsphere.apache.org/document/5.2.0/en/dev-manual/configuration/ and got some confusion.

  • AlgorithmShardingRuleConfiguration is Used to convert algorithm-based sharding user configuration into sharding rule objects, ShardingRuleConfiguration is Used to convert sharding user configuration into sharding rule objects, is there any difference in semantics?

  • I am a little surprised that the two classes are not in a parent-subclass relationship. Because I noticed that from ShardingSphere 5.1.2 to 5.2.0, most of AlgorithmShardingRuleConfiguration was replaced by ShardingRuleConfiguration, which is reflected in the design of org.apache.shardingsphere.mode.manager.ContextManager.

linghengqian avatar Sep 10 '22 17:09 linghengqian

Hi @linghengqian, AlgorithmShardingRuleConfiguration should refer to AlgorithmProvidedShardingRuleConfiguration, the documentation should be wrong. It is mainly suitable for Spring scenarios, Spring will help us complete the initialization of algorithm objects, and ShardingRuleConfiguration is suitable for non-Spring environments.

I also find it confusing to have two similar classes, are you interested in trying to merge them?

strongduanmu avatar Sep 17 '22 09:09 strongduanmu

@strongduanmu

  • I'm stumped because some of my local attempts are affected by the strange behavior of org.apache.shardingsphere.mode.manager.ContextManager#alterRuleConfiguration. The strange behavior I'm referring to ends up being something like https://github.com/apache/shardingsphere/issues/20952.

  • I'd like to have other friends to try the work of merge the two classes.

linghengqian avatar Sep 17 '22 09:09 linghengqian

@linghengqian This exception may be caused by wrong metadata, we will investigate it later.

strongduanmu avatar Sep 17 '22 09:09 strongduanmu

  • I will try to verify after https://github.com/apache/shardingsphere/pull/21037 is merged.

linghengqian avatar Sep 17 '22 15:09 linghengqian

@strongduanmu

  • After https://github.com/apache/shardingsphere/pull/21037 was merged and I tested the master branch, the metadata issue with org.apache.shardingsphere.mode.manager.ContextManager#alterRuleConfiguration was resolved.

  • From the results of my testing, https://github.com/apache/shardingsphere/issues/20952 has also been resolved.

  • Considering this issue is a question, should I close it immediately? Should merging two classes be a new issue?

linghengqian avatar Sep 19 '22 06:09 linghengqian