Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions services/apps/packages_worker/src/activities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,7 @@ export {
} from './pypi/activities'
export { getCriticalPypiCount } from './pypi/downloads/getCriticalPypiCount'
export { processNuGetBatch } from './nuget/activities'
export {
processRubyGemsCoreBatch,
processRubyGemsCriticalBatch,
processRubyGemsDependentsBatch,
} from './rubygems/activities'
export { processRubyGemsCoreBatch, processRubyGemsCriticalBatch } from './rubygems/activities'
export {
processSecurityContactsBatch,
ingestSecurityContactsForPurlActivity,
Expand Down
7 changes: 1 addition & 6 deletions services/apps/packages_worker/src/bin/rubygems-worker.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
import {
scheduleRubyGemsCriticalIngestion,
scheduleRubyGemsDependentsIngestion,
scheduleRubyGemsIngestion,
} from '../rubygems/schedule'
import { scheduleRubyGemsCriticalIngestion, scheduleRubyGemsIngestion } from '../rubygems/schedule'
import { svc } from '../service'

setImmediate(async () => {
await svc.init()
await scheduleRubyGemsIngestion()
await scheduleRubyGemsCriticalIngestion()
await scheduleRubyGemsDependentsIngestion()
await svc.start()
})
7 changes: 0 additions & 7 deletions services/apps/packages_worker/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,6 @@ export function getRubyGemsCriticalConfig() {
}
}

export function getRubyGemsDependentsConfig() {
return {
batchSize: parseInt(process.env.RUBYGEMS_DEPENDENTS_BATCH_SIZE ?? '10000', 10),
concurrency: parseInt(process.env.RUBYGEMS_DEPENDENTS_CONCURRENCY ?? '50', 10),
}
}

export function getDockerhubConfig() {
return {
hubBaseUrl: requireEnv('DOCKERHUB_API_BASE_URL'),
Expand Down
20 changes: 1 addition & 19 deletions services/apps/packages_worker/src/rubygems/activities.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,10 @@
import { getServiceChildLogger } from '@crowd/logging'

import {
getRubyGemsConfig,
getRubyGemsCriticalConfig,
getRubyGemsDependentsConfig,
} from '../config'
import { getRubyGemsConfig, getRubyGemsCriticalConfig } from '../config'
import { getPackagesDb } from '../db'

import { processBatch as processCoreBatch } from './runRubyGemsCoreLoop'
import { processBatch as processCriticalBatch } from './runRubyGemsCriticalLoop'
import {
DependentsBatchResult,
processBatch as processDependentsBatch,
} from './runRubyGemsDependentsLoop'
import { BatchResult } from './types'

const log = getServiceChildLogger('rubygems-activity')
Expand All @@ -35,13 +27,3 @@ export async function processRubyGemsCriticalBatch(
log.info({ ...result }, 'RubyGems critical batch complete')
return result
}

export async function processRubyGemsDependentsBatch(
afterId = '0',
): Promise<DependentsBatchResult> {
const config = getRubyGemsDependentsConfig()
const qx = await getPackagesDb()
const result = await processDependentsBatch(qx, config, afterId)
log.info({ ...result }, 'RubyGems dependents batch complete')
return result
}
6 changes: 0 additions & 6 deletions services/apps/packages_worker/src/rubygems/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,3 @@ export function fetchOwners(name: string): Promise<RubyGemsFetchResult<RubyGemsO
`https://rubygems.org/api/v1/gems/${encodeURIComponent(name)}/owners.json`,
)
}

export function fetchReverseDependencies(name: string): Promise<RubyGemsFetchResult<string[]>> {
return rubyGemsGet<string[]>(
`https://rubygems.org/api/v1/gems/${encodeURIComponent(name)}/reverse_dependencies.json`,
)
}

This file was deleted.

43 changes: 1 addition & 42 deletions services/apps/packages_worker/src/rubygems/schedule.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
import { ScheduleAlreadyRunning, ScheduleOverlapPolicy } from '@temporalio/client'

import { svc } from '../service'
import {
ingestRubyGemsCriticalDetails,
ingestRubyGemsDependents,
ingestRubyGemsPackages,
} from '../workflows'
import { ingestRubyGemsCriticalDetails, ingestRubyGemsPackages } from '../workflows'

export async function scheduleRubyGemsIngestion(): Promise<void> {
const { temporal } = svc
Expand Down Expand Up @@ -80,40 +76,3 @@ export async function scheduleRubyGemsCriticalIngestion(): Promise<void> {
}
}
}

export async function scheduleRubyGemsDependentsIngestion(): Promise<void> {
const { temporal } = svc
if (!temporal) throw new Error('Temporal client not initialized')

try {
await temporal.schedule.create({
scheduleId: 'rubygems-dependents-ingest',
spec: {
cronExpressions: ['0 3 * * 0'],
},
policies: {
overlap: ScheduleOverlapPolicy.SKIP,
catchupWindow: '1 hour',
},
action: {
type: 'startWorkflow',
workflowType: ingestRubyGemsDependents,
workflowId: 'rubygems-weekly-dependents',
taskQueue: 'rubygems-worker',
workflowRunTimeout: '24 hours',
retry: {
initialInterval: '30 seconds',
backoffCoefficient: 2,
maximumAttempts: 5,
},
args: [],
},
})
} catch (err) {
if (err instanceof ScheduleAlreadyRunning) {
svc.log.info('Schedule rubygems-dependents-ingest already exists, skipping creation.')
} else {
throw err
}
}
}
9 changes: 0 additions & 9 deletions services/apps/packages_worker/src/rubygems/workflows.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,3 @@ export async function ingestRubyGemsCriticalDetails(afterId = '0'): Promise<void
}
await continueAsNew<typeof ingestRubyGemsCriticalDetails>(result.lastId)
}

export async function ingestRubyGemsDependents(afterId = '0'): Promise<void> {
const result = await acts.processRubyGemsDependentsBatch(afterId)
if (result.lastId === null) {
log.info('RubyGems dependents ingestion complete — no more work, exiting.', { ...result })
return
}
await continueAsNew<typeof ingestRubyGemsDependents>(result.lastId)
}
6 changes: 1 addition & 5 deletions services/apps/packages_worker/src/workflows/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,7 @@ export {
ingestPypiDownloadsDaily,
} from '../pypi/downloads/ingestPypiDownloads'
export { ingestNuGetPackages } from '../nuget/workflows'
export {
ingestRubyGemsCriticalDetails,
ingestRubyGemsDependents,
ingestRubyGemsPackages,
} from '../rubygems/workflows'
export { ingestRubyGemsCriticalDetails, ingestRubyGemsPackages } from '../rubygems/workflows'
export {
ingestSecurityContacts,
ingestSecurityContactsForPurlWorkflow,
Expand Down
38 changes: 0 additions & 38 deletions services/libs/data-access-layer/src/osspckgs/rubygems.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,41 +62,3 @@ export async function listRubyGemsCriticalPackagesToSync(
{ limit, afterId },
)
}

export type RubyGemsPackageForDependents = {
id: string
name: string
}

export async function listRubyGemsPackagesForDependents(
qx: QueryExecutor,
options: { limit: number; afterId?: string },
): Promise<RubyGemsPackageForDependents[]> {
const { limit, afterId = '0' } = options
return qx.select(
`
SELECT p.id, p.name
FROM packages p
WHERE p.ecosystem = 'rubygems'
AND p.id > $(afterId)::bigint
ORDER BY p.id ASC
LIMIT $(limit)
`,
{ limit, afterId },
)
}

export async function updateRubyGemsDependentCount(
qx: QueryExecutor,
packageId: string,
dependentCount: number,
): Promise<void> {
await qx.result(
`UPDATE packages
SET dependent_count = $(dependentCount),
last_synced_at = NOW()
WHERE id = $(packageId)::bigint
AND dependent_count IS DISTINCT FROM $(dependentCount)`,
{ packageId, dependentCount },
)
}
Loading