-
Notifications
You must be signed in to change notification settings - Fork 428
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
feat(logs): timeout old operations #2220
Merged
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
c4f11ec
feat(logs): index policy
bodinsamuel 49abc06
not workign
bodinsamuel 306e123
maybe
bodinsamuel ecbdfef
cli
bodinsamuel d917edb
Merge branch 'master' into feat/logs-index-policy
bodinsamuel d8eaaeb
Merge branch 'master' into feat/logs-index-policy
bodinsamuel 9dc1b19
prime index
bodinsamuel f8765ed
condition has changed
bodinsamuel 12537f4
better codnition
bodinsamuel c5b5acc
feat(logs): timeout old operations
bodinsamuel 410ed63
Merge branch 'master' into feat/logs-automatic-timeout
bodinsamuel a1d0a6d
no wrapper
bodinsamuel 34050d8
smaller expiration date for connect
bodinsamuel 70090b2
default expiration
bodinsamuel 33ca3d8
default expiration date for some operation
bodinsamuel 29e63c8
abstract values
bodinsamuel 19ec768
Merge branch 'master' into feat/logs-automatic-timeout
bodinsamuel e13e10d
jesus
bodinsamuel 07925ee
Merge branch 'master' into feat/logs-automatic-timeout
bodinsamuel 7a23efb
guess what, still can't import logs in shared
bodinsamuel d2239f4
Merge branch 'master' into feat/logs-automatic-timeout
bodinsamuel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import * as cron from 'node-cron'; | ||
import { errorManager, ErrorSourceEnum } from '@nangohq/shared'; | ||
import tracer from 'dd-trace'; | ||
import { envs, model } from '@nangohq/logs'; | ||
import { getLogger } from '@nangohq/utils'; | ||
|
||
const logger = getLogger('Jobs.TimeoutLogsOperations'); | ||
|
||
export function timeoutLogsOperations(): void { | ||
if (!envs.NANGO_LOGS_ENABLED) { | ||
return; | ||
} | ||
|
||
cron.schedule( | ||
'*/10 * * * *', | ||
// eslint-disable-next-line @typescript-eslint/no-misused-promises | ||
async () => { | ||
try { | ||
logger.info(`Timeouting old operations...`); | ||
await model.setTimeoutForAll(); | ||
} catch (err) { | ||
errorManager.report(err, { source: ErrorSourceEnum.PLATFORM }, tracer); | ||
} | ||
} | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,15 @@ | ||
import { parseEnvs, ENVS } from '@nangohq/utils'; | ||
import { parseEnvs, ENVS, MAX_ACTION_DURATION, MAX_SYNC_DURATION, MAX_WEBHOOK_DURATION } from '@nangohq/utils'; | ||
|
||
// Do not require in community and enterprise right now | ||
const required = process.env['NANGO_LOGS_ENABLED'] === 'true'; | ||
|
||
export const envs = parseEnvs(required ? ENVS.required({ NANGO_LOGS_ES_URL: true, NANGO_LOGS_ES_USER: true, NANGO_LOGS_ES_PWD: true }) : ENVS); | ||
|
||
envs.NANGO_LOGS_ENABLED = Boolean(envs.NANGO_LOGS_ENABLED && envs.NANGO_LOGS_ES_URL); | ||
|
||
export const defaultOperationExpiration = { | ||
action: () => new Date(Date.now() + MAX_ACTION_DURATION).toISOString(), | ||
webhook: () => new Date(Date.now() + MAX_WEBHOOK_DURATION).toISOString(), | ||
sync: () => new Date(Date.now() + MAX_SYNC_DURATION).toISOString(), | ||
auth: () => new Date(Date.now() + 300 * 1000).toISOString() | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1 day for an action that's pretty generous
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's just for the heartbeat, unfortunately I have no way to have something more precise. But if everything works well everything should be handled by temporal/v2 :D
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be nice to abstract out these times to one place in case we need to adjust
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah good point, actually I wasn't aware of the constant you shared on previous message so maybe I can expose them globally somehow