Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Separate crawler queue connection from harvest #633

Merged
merged 1 commit into from
Feb 11, 2025
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
5 changes: 3 additions & 2 deletions config/cdConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,9 @@ module.exports = {
attenuation: {
ttl: 3000
},
spnAuth: config.get('CRAWLER_HARVESTS_QUEUE_SPN_AUTH'),
account: cd_azblob.account
spnAuth: config.get('CRAWLER_QUEUE_AZURE_SPN_AUTH') || cd_azblob.spnAuth,
account: config.get('CRAWLER_QUEUE_AZURE_ACCOUNT_NAME') || cd_azblob.account,
isSpnAuth: config.get('CRAWLER_QUEUE_AZURE_IS_SPN_AUTH') || false
},
appVersion: config.get('APP_VERSION'),
buildsha: config.get('BUILD_SHA')
Expand Down
29 changes: 19 additions & 10 deletions ghcrawler/providers/queuing/storageQueueManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,28 @@ class StorageQueueManager {
retryPolicyType: StorageRetryPolicyType.EXPONENTIAL
}
}

const { account, spnAuth, isSpnAuth } = options
if (isSpnAuth) {
const authParsed = JSON.parse(spnAuth)
this.client = new QueueServiceClient(
`https://${account}.queue.core.windows.net`,
new ClientSecretCredential(authParsed.tenantId, authParsed.clientId, authParsed.clientSecret),
pipelineOptions
)
return
}

if (connectionString) {
this.client = QueueServiceClient.fromConnectionString(connectionString, pipelineOptions)
} else {
const { account, spnAuth } = options
let credential
if (spnAuth) {
const authParsed = JSON.parse(spnAuth)
credential = new ClientSecretCredential(authParsed.tenantId, authParsed.clientId, authParsed.clientSecret)
} else {
credential = new DefaultAzureCredential()
}
this.client = new QueueServiceClient(`https://${account}.queue.core.windows.net`, credential, pipelineOptions)
return
}

this.client = new QueueServiceClient(
`https://${account}.queue.core.windows.net`,
new DefaultAzureCredential(),
pipelineOptions
)
}

createQueueClient(name, formatter, options) {
Expand Down