Skip to content

Commit b50c410

Browse files
committed
SK-2292 Update default concurrency limit from 10 to 1
- Add ability to read system env variables
1 parent 04d886d commit b50c410

2 files changed

Lines changed: 35 additions & 8 deletions

File tree

v3/src/main/java/com/skyflow/utils/Constants.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ public final class Constants extends BaseConstants {
77
public static final String SDK_PREFIX = SDK_NAME + SDK_VERSION;
88
public static final Integer INSERT_BATCH_SIZE = 50;
99
public static final Integer MAX_INSERT_BATCH_SIZE = 1000;
10-
public static final Integer INSERT_CONCURRENCY_LIMIT = 10;
10+
public static final Integer INSERT_CONCURRENCY_LIMIT = 1;
1111
public static final Integer MAX_INSERT_CONCURRENCY_LIMIT = 10;
1212

1313
public static final Integer DETOKENIZE_BATCH_SIZE = 50;
14-
public static final Integer DETOKENIZE_CONCURRENCY_LIMIT = 10;
14+
public static final Integer DETOKENIZE_CONCURRENCY_LIMIT = 1;
1515
public static final Integer MAX_DETOKENIZE_BATCH_SIZE = 1000;
1616
public static final Integer MAX_DETOKENIZE_CONCURRENCY_LIMIT = 10;
1717

v3/src/main/java/com/skyflow/vault/controller/VaultController.java

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import com.skyflow.utils.validations.Validations;
2020
import com.skyflow.vault.data.*;
2121
import io.github.cdimascio.dotenv.Dotenv;
22+
import io.github.cdimascio.dotenv.DotenvException;
2223

2324
import java.util.ArrayList;
2425
import java.util.Collections;
@@ -309,9 +310,22 @@ private InsertResponse insertBatch(List<InsertRecordData> batch, String tableNam
309310

310311
private void configureInsertConcurrencyAndBatchSize(int totalRequests) {
311312
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+
}
315329

316330
if (userProvidedBatchSize != null) {
317331
try {
@@ -365,9 +379,22 @@ private void configureInsertConcurrencyAndBatchSize(int totalRequests) {
365379

366380
private void configureDetokenizeConcurrencyAndBatchSize(int totalRequests) {
367381
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+
}
371398

372399
if (userProvidedBatchSize != null) {
373400
try {

0 commit comments

Comments
 (0)