-
Notifications
You must be signed in to change notification settings - Fork 117
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Try-catch update functions in cache-update loops. (#1042)
- Loading branch information
1 parent
5636db5
commit 087e939
Showing
4 changed files
with
48 additions
and
15 deletions.
There are no files selected for viewing
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
14 changes: 9 additions & 5 deletions
14
indexer/packages/postgres/src/loops/liquidity-tier-refresher.ts
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,20 @@ | ||
import { delay, logger } from '@dydxprotocol-indexer/base'; | ||
|
||
export async function startUpdateLoop( | ||
updateFunction: () => Promise<void>, | ||
delayMs: number, | ||
name: string, | ||
): Promise<void> { | ||
for (;;) { | ||
try { | ||
await updateFunction(); | ||
} catch (error) { | ||
logger.error({ | ||
at: name, | ||
message: 'Failed to run update', | ||
error, | ||
}); | ||
} | ||
await delay(delayMs); | ||
} | ||
} |
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