Sequences: Introduce constants for configuration keys/values

Use the existing constants for "accounts" and "changes", and add
new constants for "noteDb" and "sequenceBatchSize".

Add new constants for the default sequence batch sizes for accounts
and changes.

Change-Id: I6ed0c09bcbf4fc636fcc6a0107b75f971fb2d080
This commit is contained in:
David Pursehouse
2020-06-03 10:28:34 +09:00
parent d77faa1b58
commit a2d91d36bb

View File

@@ -31,6 +31,11 @@ import org.eclipse.jgit.lib.Config;
@Singleton @Singleton
public class Sequences { public class Sequences {
private static final String SECTION_NOTEDB = "noteDb";
private static final String KEY_SEQUENCE_BATCH_SIZE = "sequenceBatchSize";
private static final int DEFAULT_ACCOUNTS_SEQUENCE_BATCH_SIZE = 1;
private static final int DEFAULT_CHANGES_SEQUENCE_BATCH_SIZE = 20;
public static final String NAME_ACCOUNTS = "accounts"; public static final String NAME_ACCOUNTS = "accounts";
public static final String NAME_GROUPS = "groups"; public static final String NAME_GROUPS = "groups";
public static final String NAME_CHANGES = "changes"; public static final String NAME_CHANGES = "changes";
@@ -59,7 +64,12 @@ public class Sequences {
AllUsersName allUsers, AllUsersName allUsers,
MetricMaker metrics) { MetricMaker metrics) {
int accountBatchSize = cfg.getInt("noteDb", "accounts", "sequenceBatchSize", 1); int accountBatchSize =
cfg.getInt(
SECTION_NOTEDB,
NAME_ACCOUNTS,
KEY_SEQUENCE_BATCH_SIZE,
DEFAULT_ACCOUNTS_SEQUENCE_BATCH_SIZE);
accountSeq = accountSeq =
new RepoSequence( new RepoSequence(
repoManager, repoManager,
@@ -69,7 +79,12 @@ public class Sequences {
() -> FIRST_ACCOUNT_ID, () -> FIRST_ACCOUNT_ID,
accountBatchSize); accountBatchSize);
int changeBatchSize = cfg.getInt("noteDb", "changes", "sequenceBatchSize", 20); int changeBatchSize =
cfg.getInt(
SECTION_NOTEDB,
NAME_CHANGES,
KEY_SEQUENCE_BATCH_SIZE,
DEFAULT_CHANGES_SEQUENCE_BATCH_SIZE);
changeSeq = changeSeq =
new RepoSequence( new RepoSequence(
repoManager, repoManager,