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

feat: refactor #326

Merged
merged 1 commit into from
Sep 6, 2024
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
20 changes: 8 additions & 12 deletions packages/network-support/src/scoreManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {
getLatencyScoreWeight,
} from './utils/score';
import { Version } from './utils/version';
import timeBarrier from './utils/timeBarer';

type Options = {
logger: Logger;
Expand Down Expand Up @@ -164,17 +163,14 @@ export class ScoreManager {
this.scoreStore.set(key, score);
extraLog = extraLog || {};

if (score.score <= 1) {
const inserted = timeBarrier.set(`${this.projectId}_${runner}`);
if (inserted && this.notifyFunc) {
this.notifyFunc({
text: `*Title*: score down from ${before} to ${score.score}\n*DeploymentId*: ${
this.projectId
}\n*Indexer*: ${runner}\n*Info*: ${errorType} - ${JSON.stringify(
extraLog
)}\n*TimeBarrier*: ${timeBarrier.inspect()}\n*Time*: ${new Date().toISOString()}`,
});
}
if (score.score <= 1 && this.notifyFunc) {
this.notifyFunc(`${this.projectId}_${runner}`, {
text: `*Title*: score down from ${before} to ${score.score}\n*DeploymentId*: ${
this.projectId
}\n*Indexer*: ${runner}\n*Info*: ${errorType} - ${JSON.stringify(
extraLog
)}\n*Time*: ${new Date().toISOString()}`,
});
}

this.logger?.info({
Expand Down
2 changes: 1 addition & 1 deletion packages/network-support/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,4 @@ export type ScoreWithDetail = {
scoreDetail: Record<SCORE_DETAIL_TYPE, number>;
};

export type NotifyFunc = (data: any, headers?: Record<string, string>) => Promise<void>;
export type NotifyFunc = (id: string, data: any, headers?: Record<string, string>) => Promise<void>;
1 change: 0 additions & 1 deletion packages/network-support/src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,3 @@ export * from './auth';
export * from './uniqueId';
export * from './common';
export * from './score';
export * from './timeBarer';
35 changes: 0 additions & 35 deletions packages/network-support/src/utils/timeBarer.ts

This file was deleted.

Loading