|
19 | 19 | import com.skyflow.utils.validations.Validations; |
20 | 20 | import com.skyflow.vault.data.*; |
21 | 21 | import io.github.cdimascio.dotenv.Dotenv; |
| 22 | +import io.github.cdimascio.dotenv.DotenvException; |
22 | 23 |
|
23 | 24 | import java.util.ArrayList; |
24 | 25 | import java.util.Collections; |
@@ -309,9 +310,22 @@ private InsertResponse insertBatch(List<InsertRecordData> batch, String tableNam |
309 | 310 |
|
310 | 311 | private void configureInsertConcurrencyAndBatchSize(int totalRequests) { |
311 | 312 | try { |
312 | | - Dotenv dotenv = Dotenv.load(); |
313 | | - String userProvidedBatchSize = dotenv.get("INSERT_BATCH_SIZE"); |
314 | | - String userProvidedConcurrencyLimit = dotenv.get("INSERT_CONCURRENCY_LIMIT"); |
| 313 | + String userProvidedBatchSize = System.getenv("INSERT_BATCH_SIZE"); |
| 314 | + String userProvidedConcurrencyLimit = System.getenv("INSERT_CONCURRENCY_LIMIT"); |
| 315 | + |
| 316 | + Dotenv dotenv = null; |
| 317 | + try { |
| 318 | + dotenv = Dotenv.load(); |
| 319 | + } catch (DotenvException ignored) { |
| 320 | + // ignore the case if .env file is not found |
| 321 | + } |
| 322 | + |
| 323 | + if (userProvidedBatchSize == null && dotenv != null) { |
| 324 | + userProvidedBatchSize = dotenv.get("INSERT_BATCH_SIZE"); |
| 325 | + } |
| 326 | + if (userProvidedConcurrencyLimit == null && dotenv != null) { |
| 327 | + userProvidedConcurrencyLimit = dotenv.get("INSERT_CONCURRENCY_LIMIT"); |
| 328 | + } |
315 | 329 |
|
316 | 330 | if (userProvidedBatchSize != null) { |
317 | 331 | try { |
@@ -365,9 +379,22 @@ private void configureInsertConcurrencyAndBatchSize(int totalRequests) { |
365 | 379 |
|
366 | 380 | private void configureDetokenizeConcurrencyAndBatchSize(int totalRequests) { |
367 | 381 | try { |
368 | | - Dotenv dotenv = Dotenv.load(); |
369 | | - String userProvidedBatchSize = dotenv.get("DETOKENIZE_BATCH_SIZE"); |
370 | | - String userProvidedConcurrencyLimit = dotenv.get("DETOKENIZE_CONCURRENCY_LIMIT"); |
| 382 | + String userProvidedBatchSize = System.getenv("DETOKENIZE_BATCH_SIZE"); |
| 383 | + String userProvidedConcurrencyLimit = System.getenv("DETOKENIZE_BATCH_SIZE"); |
| 384 | + |
| 385 | + Dotenv dotenv = null; |
| 386 | + try { |
| 387 | + dotenv = Dotenv.load(); |
| 388 | + } catch (DotenvException ignored) { |
| 389 | + // ignore the case if .env file is not found |
| 390 | + } |
| 391 | + |
| 392 | + if (userProvidedBatchSize == null && dotenv != null) { |
| 393 | + userProvidedBatchSize = dotenv.get("DETOKENIZE_BATCH_SIZE"); |
| 394 | + } |
| 395 | + if (userProvidedConcurrencyLimit == null && dotenv != null) { |
| 396 | + userProvidedConcurrencyLimit = dotenv.get("DETOKENIZE_BATCH_SIZE"); |
| 397 | + } |
371 | 398 |
|
372 | 399 | if (userProvidedBatchSize != null) { |
373 | 400 | try { |
|
0 commit comments