Skip to content
This repository has been archived by the owner on Jul 9, 2024. It is now read-only.

Commit

Permalink
Don't retry in go by default, increase batch sizing for DB
Browse files Browse the repository at this point in the history
  • Loading branch information
aquarat committed Oct 20, 2023
1 parent cfcea89 commit 1071693
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/alerting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ const dbWriterLoop = async () => {

dbWriterInitialised = true;

dbWriterInterval = setInterval(writeRecords, 5_000);
dbWriterInterval = setInterval(writeRecords, 10_000);

if (process.env.DEBUG_DB_WRITER) {
setInterval(() => {
Expand Down
6 changes: 4 additions & 2 deletions src/fetch-beacon-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ export const fetchBeaconDataInLoop = async (beaconId: string) => {
const { config } = getState();
const { fetchInterval } = config.beacons[beaconId];

setInterval(() => fetchBeaconData(beaconId), fetchInterval * 1_000);
const fetchBeaconDataCallback = () => fetchBeaconData(beaconId);
setInterval(fetchBeaconDataCallback, fetchInterval * 1_000);
fetchBeaconDataCallback();
};

export const fetchBeaconData = async (beaconId: string) => {
Expand Down Expand Up @@ -76,7 +78,7 @@ export const fetchBeaconData = async (beaconId: string) => {
}

const goRes = await go(fetchFn, {
retries: 2,
retries: 0,
delay: { type: 'random', minDelayMs: RANDOM_BACKOFF_MIN_MS, maxDelayMs: RANDOM_BACKOFF_MAX_MS },
onAttemptError,
});
Expand Down
9 changes: 5 additions & 4 deletions src/update-data-feeds.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,11 @@ export const initiateDataFeedUpdates = () => {
export const updateDataFeedsInLoop = async (providerSponsorDataFeeds: ProviderSponsorDataFeeds) => {
const { updateInterval } = providerSponsorDataFeeds;

setInterval(
() => Promise.allSettled([updateBeacons(providerSponsorDataFeeds), updateBeaconSets(providerSponsorDataFeeds)]),
updateInterval * 1_000
);
const intervalCallback = () =>
Promise.allSettled([updateBeacons(providerSponsorDataFeeds), updateBeaconSets(providerSponsorDataFeeds)]);

setInterval(intervalCallback, updateInterval * 1_000);
intervalCallback();
};

// We pass return value from `prepareGoOptions` (with calculated timeout) to every `go` call in the function to enforce the update cycle.
Expand Down
1 change: 1 addition & 0 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ export const calculateTimeout = (startTime: number, totalTimeout: number) => tot

export const prepareGoOptions = (): GoAsyncOptions => ({
delay: { type: 'random' as const, minDelayMs: RANDOM_BACKOFF_MIN_MS, maxDelayMs: RANDOM_BACKOFF_MAX_MS },
retries: 0,
});

0 comments on commit 1071693

Please sign in to comment.