TeslaCN commented on code in PR #2184:
URL: 
https://github.com/apache/shardingsphere-elasticjob/pull/2184#discussion_r1115145807


##########
elasticjob-ecosystem/elasticjob-tracing/elasticjob-tracing-rdb/src/main/java/org/apache/shardingsphere/elasticjob/tracing/rdb/storage/RDBJobEventStorage.java:
##########
@@ -61,14 +63,41 @@ public final class RDBJobEventStorage {
     private final DatabaseType databaseType;
     
     private final RDBStorageSQLMapper sqlMapper;
+
+    private static final Map<DataSource, RDBJobEventStorage> STORAGE_MAP = new 
ConcurrentHashMap<>();
+
     
     static {
         for (DatabaseType each : ServiceLoader.load(DatabaseType.class)) {
             DATABASE_TYPES.put(each.getType(), each);
         }
     }
+
+    public static RDBJobEventStorage getInstance(final DataSource dataSource) 
throws SQLException {
+        return wrapException(() -> STORAGE_MAP.computeIfAbsent(dataSource, 
(ds) -> {
+            try {
+                return new RDBJobEventStorage(ds);
+            } catch (SQLException e) {
+                throw new RuntimeException(e);
+            }
+        }));
+    }
+
+    public static RDBJobEventStorage 
wrapException(Callable<RDBJobEventStorage> callable) throws SQLException {

Review Comment:
   How about using `Supplier` instead of `Callable`?



-- 
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