You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2020/01/07 03:20:26 UTC

[GitHub] [incubator-shardingsphere] kekerzzZ opened a new issue #3886: Can we consider sharing the pool of sharded data source connections?

kekerzzZ opened a new issue #3886: Can we consider sharing the pool of sharded data source connections?
URL: https://github.com/apache/incubator-shardingsphere/issues/3886
 
 
   ### Is your feature request related to a problem?
   Yes.
   
   ### Describe the feature you would like.
   
   - Each shard needs to reconfigure the connection pool. Is it possible to add switches for users to choose whether to share or not.
   
   - Now I have customized SpringBootConfiguration to achieve the purpose of reuse.
   
   ```
    /**
        * 获取数据库连接池前缀
        */
       private String getDataSourcePoolName(Environment environment) {
           return environment.getProperty(datasourcePoolPrefix, "spring.datasource.druid");
       }
   
       private List<String> getDataSourceNames(final Environment environment, final String prefix) {
           StandardEnvironment standardEnv = (StandardEnvironment) environment;
           standardEnv.setIgnoreUnresolvableNestedPlaceholders(true);
           return null == standardEnv.getProperty(prefix + "name")
                   ? new InlineExpressionParser(standardEnv.getProperty(prefix + "names")).splitAndEvaluate() : Collections.singletonList(standardEnv.getProperty(prefix + "name"));
       }
   
       @SuppressWarnings("unchecked")
       private DataSource getDataSource(final Environment environment, final String prefix, final String dataSourceName, Map<String, Object> dataSourcePoolMap) throws ReflectiveOperationException {
           // 解析分库配置
           Map<String, Object> dataSourceProps = PropertyUtil.handle(environment, prefix + dataSourceName.trim(), Map.class);
           Preconditions.checkState(!dataSourceProps.isEmpty(), "Wrong datasource properties!");
           // 将数据库连接池配置放到分库配置中
           if (!dataSourcePoolMap.isEmpty()) {
               dataSourceProps.putAll(dataSourcePoolMap);
           }
           return DataSourceUtil.getDataSource(dataSourceProps.get("type").toString(), dataSourceProps);
       }
   ```
   
   - Is this reasonable?
   

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-shardingsphere] terrymanu closed issue #3886: Can we consider sharing the pool of sharded data source connections?

Posted by GitBox <gi...@apache.org>.
terrymanu closed issue #3886: Can we consider sharing the pool of sharded data source connections?
URL: https://github.com/apache/incubator-shardingsphere/issues/3886
 
 
   

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-shardingsphere] terrymanu commented on issue #3886: Can we consider sharing the pool of sharded data source connections?

Posted by GitBox <gi...@apache.org>.
terrymanu commented on issue #3886: Can we consider sharing the pool of sharded data source connections?
URL: https://github.com/apache/incubator-shardingsphere/issues/3886#issuecomment-571482780
 
 
   Share pool config may let user confuse, for each connection pool should has independent config.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services