Skip to content

Commit

Permalink
chore: rename M365_EXCEL_DELAY_BETWEEN_ACTIONS_MS
Browse files Browse the repository at this point in the history
  • Loading branch information
ogp-weeloong committed May 8, 2024
1 parent 6fabc5f commit 998be5b
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 9 deletions.
4 changes: 2 additions & 2 deletions ecs/env.json
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,8 @@
"valueFrom": "plumber-<ENVIRONMENT>-max-job-attempts"
},
{
"name": "M365_EXCEL_DELAY_BETWEEN_ACTIONS_MS",
"valueFrom": "plumber-<ENVIRONMENT>-m365-excel-delay-between-actions-ms"
"name": "M365_EXCEL_INTERVAL_BETWEEN_ACTIONS_MS",
"valueFrom": "plumber-<ENVIRONMENT>-m365-excel-interval-between-actions-ms"
}
]
}
1 change: 1 addition & 0 deletions packages/backend/.env-example
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,4 @@ M365_LOCAL_DEV_CLIENT_ID=...
M365_LOCAL_DEV_CLIENT_THUMBPRINT=...
M365_LOCAL_DEV_CLIENT_PRIVATE_KEY=...
M365_LOCAL_DEV_ALLOWED_SENSITIVITY_LABEL_GUIDS_CSV=11111111-1111-1111-1111-111111111111
M365_EXCEL_INTERVAL_BETWEEN_ACTIONS_MS=1000
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ vi.mock('@/helpers/logger', () => ({
}))

vi.mock('@/config/app-env-vars/m365', () => ({
M365_EXCEL_DELAY_BETWEEN_ACTIONS_MS: 1000,
M365_EXCEL_INTERVAL_BETWEEN_ACTIONS_MS: 1000,
isM365TenantKey: vi.fn(() => true),
}))

Expand Down
4 changes: 2 additions & 2 deletions packages/backend/src/apps/m365-excel/queue/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { IAppQueue } from '@plumber/types'

import { M365_EXCEL_DELAY_BETWEEN_ACTIONS_MS } from '@/config/app-env-vars/m365'
import { M365_EXCEL_INTERVAL_BETWEEN_ACTIONS_MS } from '@/config/app-env-vars/m365'
import Step from '@/models/step'

//
Expand Down Expand Up @@ -47,7 +47,7 @@ const queueSettings = {
isQueueDelayable: true,
queueRateLimit: {
max: 1,
duration: M365_EXCEL_DELAY_BETWEEN_ACTIONS_MS,
duration: M365_EXCEL_INTERVAL_BETWEEN_ACTIONS_MS,
},
} satisfies IAppQueue

Expand Down
17 changes: 13 additions & 4 deletions packages/backend/src/config/app-env-vars/m365.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,22 @@ export const M365_STEPS_LIMIT_PER_SEC = Number(
process.env.M365_STEPS_LIMIT_PER_SEC ?? 1,
)

if (!appConfig) {
throw new Error('Cyclic import of appConfig from app-env-vars')
}

// Default to 1 action per second.
export const M365_EXCEL_DELAY_BETWEEN_ACTIONS_MS = Number(
process.env.M365_EXCEL_DELAY_BETWEEN_ACTIONS_MS ?? 1000,
export const M365_EXCEL_INTERVAL_BETWEEN_ACTIONS_MS = Number(
process.env.M365_EXCEL_INTERVAL_BETWEEN_ACTIONS_MS ?? '1000',
)

if (!appConfig) {
throw new Error('Cyclic import of appConfig from app-env-vars')
if (
isNaN(M365_EXCEL_INTERVAL_BETWEEN_ACTIONS_MS) ||
!Number.isInteger(M365_EXCEL_INTERVAL_BETWEEN_ACTIONS_MS)
) {
throw new Error(
'M365_EXCEL_INTERVAL_BETWEEN_ACTIONS_MS environment variable is not a valid integer!',
)
}

const sensitivityLabelGuidsSchema = z
Expand Down

0 comments on commit 998be5b

Please sign in to comment.