Harif-Rahman opened a new issue, #25102:
URL: https://github.com/apache/shardingsphere/issues/25102

   ## Question
   
   **For English only**, other languages will not accept.
   We are planning to upgrade shardingsphere from 4.0.1 to 5.x
   
   We already have customshardingalgorithm to get the shard id from on 
datastore like redis.
   
   4.0.1 code : 
   shardingRuleConfig.setDefaultDatabaseShardingStrategyConfig(new 
ComplexShardingStrategyConfiguration(CLIENT_ID, appShardingAlgorithm));
   
   
   @Component
   public class AppShardingAlgorithm implements 
ComplexKeysShardingAlgorithm<Long> {
     private final ShardService shardService;
   
     @Autowired
     public AppShardingAlgorithm(
         ShardService shardService
     ) {
       this.shardService = shardService;
     }
   
     @Override
     @SuppressWarnings("unchecked")
     public Collection<String> doSharding(Collection<String> 
availableTargetNames, ComplexKeysShardingValue<Long> shardingValues) {
       // get shard id from redis
       return applicableTargetNames;
     }
   }
   
   In the version 5.x i can't able to pass the custom object like i used 
earlier whatever the doc i referred its expecting me to pass it as class_based 
like the below : 
   
   [ shardingRuleConfig.setDefaultDatabaseShardingStrategy(new 
ComplexShardingStrategyConfiguration(CLIENT_ID, "appShardingAlgorithm"));
       Properties propsComplex = new Properties();
       propsComplex.setProperty("strategy", "COMPLEX");
       propsComplex.setProperty("algorithmClassName",
           "a.b.c.AppShardingAlgorithm");
       shardingRuleConfig.getShardingAlgorithms().put("appShardingAlgorithm", 
new AlgorithmConfiguration("CLASS_BASED", propsComplex));](url)
   
   In AppShardingAlgorithm class i have dependency to get the shard details 
from db or redis in this case i need to have that dependency for this.
   In this case how to pass the custom object for the sharding algorithm ?
   
   Before asking a question, make sure you have:
   
   - Googled your question.
   - Searched open and closed [GitHub 
issues](https://github.com/apache/shardingsphere/issues).
   - Read documentation: [ShardingSphere 
Doc](https://shardingsphere.apache.org/document/current/en/overview).
   
   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**.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: 
[email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to