johnny2002 edited a comment on issue #7471:
URL: https://github.com/apache/shardingsphere/issues/7471#issuecomment-699626194


   ```yaml
   #
   # Licensed to the Apache Software Foundation (ASF) under one or more
   # contributor license agreements.  See the NOTICE file distributed with
   # this work for additional information regarding copyright ownership.
   # The ASF licenses this file to You under the Apache License, Version 2.0
   # (the "License"); you may not use this file except in compliance with
   # the License.  You may obtain a copy of the License at
   #
   #     http://www.apache.org/licenses/LICENSE-2.0
   #
   # Unless required by applicable law or agreed to in writing, software
   # distributed under the License is distributed on an "AS IS" BASIS,
   # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   # See the License for the specific language governing permissions and
   # limitations under the License.
   #
   dataSourceTemplates:
     template1:
       driver-class-name: com.mysql.jdbc.Driver
       username: root
       password:
       maxPoolSize: 50
       minPoolSize: 
     template2:
       driver-class-name: org.postgresql.Driver
       username: user1
       password: pass123
       maxPoolSize: 200
       minPoolSize: 1
   
   dataSources:
     ds_0:
       template: template1
       url: 
jdbc:mysql://127.0.0.1:3306/demo_ds_0?serverTimezone=UTC&useSSL=false
       maxPoolSize: 60 #overrides 50 from template1
     ds_1:
       template: template1
       url: 
jdbc:mysql://127.0.0.1:3306/demo_ds_1?serverTimezone=UTC&useSSL=false
     ds_2:
       template: template2
       url: 
jdbc:postgresql://localhost:5432,localhost:5433/postgres?loadBalanceHosts=true&characterEncoding=utf-8
   
   rules:
   - !SHARDING
     shardingTables:
       - #Sample1: all tables Sharding by item_id should be under this group
         tables: t_order, t_order_item
         actualDataNodes: ds_${0..1}.${LOGIC_TABLE}${0..4} #${LOGIC_TABLE} will 
be replaced by INLINE strategy implementation
         tableStrategy:
           type: INLINE #Standard in house implementation
           #column: order_id
           columns: order_id #use columns to consolidate with "complex" config
           #algorithm-expression: t_order${order_id % 5}
           algorithm-expression: ${order_id % 5} #logic_table_name already been 
defined in "actualDataNodes", so no need to repeat it here, just define the 
expression to calculate ${0..4} in actualDataNodes
       - #Sample2: all tables Sharding by month of date should be under this 
group
         tables: t_access_log, t_sec_log
         tableStrategy:
           actualDataNodes: ds_${0..1}.${LOGIC_TABLE} # tables divided by date, 
so don't how many tables here.
           type: com.ibm.ibank.dmf.shardingshpere.ext.TxDateShardingAlgorithm 
#Customize sharding implementation
           columns: create_date
     defaultDatabaseStrategy:
       type: INLINE
       columns: user_id
       #algorithm-expression: ${order_id % 2}
       props: #use generic props, we can let developers pass any parameters to 
the under strategy implementation
         algorithm-expression: ${order_id % 2}
     defaultTableStrategy:
       type: INLINE
       columns: order_id
       #algorithm-expression: ${order_id % 2}
       props:
         algorithm-expression: ${order_id % 2}
         
     keyGenerateStrategies:
       - #sample1
         tables: t_order
         column: order_id
         #keyGenerator: INCREMENT
         keyGenerator: #add type so that keyGenerator can be customized
           type: SNOWFLAK
       - #sample2
         tables: t_order_item
         column: order_item_id
         keyGenerator: 
           type: INCREMEN
       - #sample3
         tables: t_user
         column: id
         keyGenerator: 
           type: INCREMEN
     autoTables: #not really understand auto-tables currently, will optimize 
later!!!
       -
         tables: t_order_auto, t_order_item_auto
         actualDataSources: ds_0, ds_1
         shardingStrategy:
           columns: order_id
           shardingAlgorithm:
             type: MOD
             props:
               sharding-count: 2
     bindingTables:
       - t_order,t_order_item
       - t_access_log, t_sec_log
     broadcastTables:
       - t_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:
[email protected]


Reply via email to