Skip to content

Commit f6ad4b3

Browse files
wip
1 parent 81c4190 commit f6ad4b3

7 files changed

Lines changed: 28 additions & 22 deletions

File tree

docs/snippets/schemas/v3/index.schema.mdx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,7 @@
4343
"maxConnectionSyncJobConcurrency": {
4444
"type": "number",
4545
"description": "The number of connection sync jobs to run concurrently. Defaults to 2.",
46-
"minimum": 1,
47-
"deprecated": true
46+
"minimum": 1
4847
},
4948
"maxRepoIndexingJobConcurrency": {
5049
"type": "number",
@@ -230,8 +229,7 @@
230229
"maxConnectionSyncJobConcurrency": {
231230
"type": "number",
232231
"description": "The number of connection sync jobs to run concurrently. Defaults to 2.",
233-
"minimum": 1,
234-
"deprecated": true
232+
"minimum": 1
235233
},
236234
"maxRepoIndexingJobConcurrency": {
237235
"type": "number",

packages/backend/src/connectionWorkload.ts

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,22 @@
1-
import { Workload } from "./types.js";
2-
import { prisma } from "./prisma.js";
1+
import { Settings, Workload } from "./types.js";
32
import { ConnectionConfig } from "@sourcebot/schemas/v3/index.type";
43
import { compileAzureDevOpsConfig, compileBitbucketConfig, compileGenericGitHostConfig, compileGerritConfig, compileGiteaConfig, compileGithubConfig, compileGitlabConfig } from "./repoCompileUtils.js";
54
import { CONNECTION_QUEUE, env, loadConfig } from "@sourcebot/shared";
65
import { syncSearchContexts } from "./ee/syncSearchContexts.js";
76
import * as Sentry from "@sentry/node";
7+
import { PrismaClient } from "@sourcebot/db";
88

9-
export const connectionWorkload: Workload<'connection'> = {
9+
interface Props {
10+
db: PrismaClient,
11+
settings: Settings;
12+
}
13+
14+
export const createConnectionWorkload = ({
15+
db,
16+
settings
17+
}: Props): Workload<'connection'> => ({
1018
queueSpec: CONNECTION_QUEUE,
11-
concurrency: 2,
19+
concurrency: settings.maxConnectionSyncJobConcurrency,
1220
process: async ({
1321
data: {
1422
connectionId,
@@ -21,7 +29,7 @@ export const connectionWorkload: Workload<'connection'> = {
2129
connectionId,
2230
orgId,
2331
});
24-
const connection = await prisma.connection.findUniqueOrThrow({
32+
const connection = await db.connection.findUniqueOrThrow({
2533
where: {
2634
id: connectionId
2735
}
@@ -55,7 +63,7 @@ export const connectionWorkload: Workload<'connection'> = {
5563
// captured by the connection's config (e.g., it was deleted, marked archived, etc.), it won't
5664
// appear in the repoData array above, and so the RepoToConnection record won't be re-created.
5765
// Repos that have no RepoToConnection records are considered orphaned and can be deleted.
58-
await prisma.$transaction(async (tx) => {
66+
await db.$transaction(async (tx) => {
5967
const deleteStart = performance.now();
6068
await tx.connection.update({
6169
where: {
@@ -104,7 +112,7 @@ export const connectionWorkload: Workload<'connection'> = {
104112
});
105113
}, { timeout: env.CONNECTION_MANAGER_UPSERT_TIMEOUT_MS });
106114

107-
await prisma.connection.update({
115+
await db.connection.update({
108116
where: {
109117
id: connectionId,
110118
},
@@ -131,7 +139,7 @@ export const connectionWorkload: Workload<'connection'> = {
131139
connectionId,
132140
});
133141
}
134-
}
142+
})
135143

136144
const discoverConnectionRepositories = async ({
137145
config,

packages/backend/src/index.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { prisma } from "./prisma.js";
1313
import { PromClient } from './promClient.js';
1414
import { createReconciliationWorkload } from "./reconciliationWorkload.js";
1515
import { redis } from "./redis.js";
16-
import { connectionWorkload } from "./connectionWorkload.js";
16+
import { connectionWorkload, createConnectionWorkload } from "./connectionWorkload.js";
1717
import { cleanupOrphanedRepoResources, createRepoIndexWorkload } from "./repoIndexWorkload.js";
1818
import { Api } from "./api.js";
1919

@@ -51,6 +51,10 @@ const reconciliationWorkload = createReconciliationWorkload({
5151
db: prisma,
5252
settings,
5353
});
54+
const connectionWorkload = createConnectionWorkload({
55+
db: prisma,
56+
settings,
57+
});
5458
const repoIndexWorkload = createRepoIndexWorkload({
5559
db: prisma,
5660
settings,

packages/backend/src/repoIndexWorkload.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@ import { cleanupTempShards, indexGitRepository } from './zoekt.js';
1313
const LOG_TAG = 'repo-index-workload';
1414
const logger = createLogger(LOG_TAG);
1515

16-
interface RepoIndexWorkloadDependencies {
16+
interface Props {
1717
db: PrismaClient;
1818
settings: Settings;
1919
}
2020

2121
export const createRepoIndexWorkload = ({
2222
db,
2323
settings,
24-
}: RepoIndexWorkloadDependencies): Workload<'repo-index'> => ({
24+
}: Props): Workload<'repo-index'> => ({
2525
queueSpec: REPO_INDEX_QUEUE,
2626
concurrency: settings.maxRepoIndexingJobConcurrency,
2727
process: async ({ data, logger: jobLogger, signal }) => {

packages/schemas/src/v3/index.schema.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,7 @@ const schema = {
4242
"maxConnectionSyncJobConcurrency": {
4343
"type": "number",
4444
"description": "The number of connection sync jobs to run concurrently. Defaults to 2.",
45-
"minimum": 1,
46-
"deprecated": true
45+
"minimum": 1
4746
},
4847
"maxRepoIndexingJobConcurrency": {
4948
"type": "number",
@@ -229,8 +228,7 @@ const schema = {
229228
"maxConnectionSyncJobConcurrency": {
230229
"type": "number",
231230
"description": "The number of connection sync jobs to run concurrently. Defaults to 2.",
232-
"minimum": 1,
233-
"deprecated": true
231+
"minimum": 1
234232
},
235233
"maxRepoIndexingJobConcurrency": {
236234
"type": "number",

packages/schemas/src/v3/index.type.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,6 @@ export interface Settings {
110110
*/
111111
reindexRepoPollingIntervalMs?: number;
112112
/**
113-
* @deprecated
114113
* The number of connection sync jobs to run concurrently. Defaults to 2.
115114
*/
116115
maxConnectionSyncJobConcurrency?: number;

schemas/v3/index.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,7 @@
4141
"maxConnectionSyncJobConcurrency": {
4242
"type": "number",
4343
"description": "The number of connection sync jobs to run concurrently. Defaults to 2.",
44-
"minimum": 1,
45-
"deprecated": true
44+
"minimum": 1
4645
},
4746
"maxRepoIndexingJobConcurrency": {
4847
"type": "number",

0 commit comments

Comments
 (0)