Skip to content

Commit

Permalink
Merge pull request #363 from Uniswap/remove-mock-handler
Browse files Browse the repository at this point in the history
chore: remove dead code
  • Loading branch information
ConjunctiveNormalForm authored Aug 1, 2024
2 parents 8528862 + 4c4e67d commit 042fdaf
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 368 deletions.
44 changes: 1 addition & 43 deletions bin/stacks/cron-stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import * as path from 'path';

import { ITopic } from 'aws-cdk-lib/aws-sns';
import { DYNAMO_TABLE_KEY, DYNAMO_TABLE_NAME, FADE_RATE_BUCKET } from '../../lib/constants';
import { CircuitBreakerMetricDimension, Metric } from '../../lib/entities';
import { PARTITION_KEY } from '../../lib/repositories/switch-repository';
import { STAGE } from '../../lib/util/stage';
import { PROD_TABLE_CAPACITY } from '../config';
Expand Down Expand Up @@ -46,14 +45,13 @@ export interface CronStackProps extends cdk.NestedStackProps {
}

export class CronStack extends cdk.NestedStack {
public readonly fadeRateCronLambda?: aws_lambda_nodejs.NodejsFunction;
public readonly fadeRateV2CronLambda?: aws_lambda_nodejs.NodejsFunction;
public readonly synthSwitchCronLambda: aws_lambda_nodejs.NodejsFunction;
public readonly redshiftReaperCronLambda: aws_lambda_nodejs.NodejsFunction;

constructor(scope: Construct, name: string, props: CronStackProps) {
super(scope, name, props);
const { RsDatabase, RsClusterIdentifier, RedshiftCredSecretArn, lambdaRole, chatbotSNSArn, stage, envVars } = props;
const { RsDatabase, RsClusterIdentifier, RedshiftCredSecretArn, lambdaRole, stage, envVars } = props;

new s3.Bucket(this, 'FadeRateS3', {
blockPublicAccess: s3.BlockPublicAccess.BLOCK_ALL,
Expand All @@ -63,42 +61,6 @@ export class CronStack extends cdk.NestedStack {

let chatbotTopic: ITopic | undefined;
if (stage == STAGE.PROD || STAGE.LOCAL) {
this.fadeRateCronLambda = new aws_lambda_nodejs.NodejsFunction(this, `${SERVICE_NAME}FadeRate`, {
role: lambdaRole,
runtime: aws_lambda.Runtime.NODEJS_18_X,
entry: path.join(__dirname, '../../lib/cron/fade-rate.ts'),
handler: 'handler',
timeout: Duration.seconds(240),
memorySize: 512,
bundling: {
minify: true,
sourceMap: true,
},
environment: {
REDSHIFT_DATABASE: RsDatabase,
REDSHIFT_CLUSTER_IDENTIFIER: RsClusterIdentifier,
REDSHIFT_SECRET_ARN: RedshiftCredSecretArn,
stage: stage,
...envVars,
},
});
new aws_events.Rule(this, `${SERVICE_NAME}ScheduleCronLambda`, {
schedule: aws_events.Schedule.rate(Duration.minutes(10)),
targets: [new aws_events_targets.LambdaFunction(this.fadeRateCronLambda)],
});

const circuitBreakerTriggeredAlarm = new aws_cloudwatch.Alarm(this, `CircuitBreakerAlarmSev3`, {
alarmName: `UniswapXParameterizationAPI-SEV3-CircuitBreaker`,
metric: new aws_cloudwatch.Metric({
metricName: Metric.CIRCUIT_BREAKER_TRIGGERED,
namespace: 'Uniswap',
dimensionsMap: CircuitBreakerMetricDimension,
statistic: 'sum',
}),
threshold: 1,
evaluationPeriods: 1,
});

this.fadeRateV2CronLambda = new aws_lambda_nodejs.NodejsFunction(this, `FadeRateV2Cron`, {
role: lambdaRole,
runtime: aws_lambda.Runtime.NODEJS_18_X,
Expand All @@ -123,10 +85,6 @@ export class CronStack extends cdk.NestedStack {
targets: [new aws_events_targets.LambdaFunction(this.fadeRateV2CronLambda)],
});

if (chatbotSNSArn) {
chatbotTopic = cdk.aws_sns.Topic.fromTopicArn(this, 'ChatbotTopic', chatbotSNSArn);
circuitBreakerTriggeredAlarm.addAlarmAction(new cdk.aws_cloudwatch_actions.SnsAction(chatbotTopic));
}
/* RFQ fade rate table */
const fadesTable = new aws_dynamo.Table(this, `${SERVICE_NAME}FadesTable`, {
tableName: DYNAMO_TABLE_NAME.FADES,
Expand Down
88 changes: 0 additions & 88 deletions lib/cron/fade-rate.ts

This file was deleted.

81 changes: 2 additions & 79 deletions lib/handlers/quote/injector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,17 @@ import {
BETA_COMPLIANCE_S3_KEY,
BETA_S3_KEY,
COMPLIANCE_CONFIG_BUCKET,
FADE_RATE_BUCKET,
FADE_RATE_S3_KEY,
INTEGRATION_S3_KEY,
PRODUCTION_S3_KEY,
PROD_COMPLIANCE_S3_KEY,
WEBHOOK_CONFIG_BUCKET,
} from '../../constants';
import {
AWSMetricsLogger,
SoftQuoteMetricDimension,
UniswapXParamServiceIntegrationMetricDimension,
} from '../../entities/aws-metrics-logger';
import { AWSMetricsLogger, SoftQuoteMetricDimension } from '../../entities/aws-metrics-logger';
import { S3WebhookConfigurationProvider } from '../../providers';
import { FirehoseLogger } from '../../providers/analytics';
import { DynamoCircuitBreakerConfigurationProvider } from '../../providers/circuit-breaker/dynamo';
import { S3CircuitBreakerConfigurationProvider } from '../../providers/circuit-breaker/s3';
import { S3FillerComplianceConfigurationProvider } from '../../providers/compliance/s3';
import { Quoter, WebhookQuoter } from '../../quoters';
import {
DynamoFillerAddressRepository,
MockFillerAddressRepository,
} from '../../repositories/filler-address-repository';
import { DynamoFillerAddressRepository } from '../../repositories/filler-address-repository';
import { STAGE } from '../../util/stage';
import { ApiInjector, ApiRInj } from '../base/api-handler';
import { PostQuoteRequestBody } from './schema';
Expand Down Expand Up @@ -120,69 +109,3 @@ export class QuoteInjector extends ApiInjector<ContainerInjected, RequestInjecte
};
}
}

export class MockQuoteInjector extends ApiInjector<ContainerInjected, RequestInjected, PostQuoteRequestBody, void> {
public async buildContainerInjected(): Promise<ContainerInjected> {
const log: Logger = bunyan.createLogger({
name: this.injectorName,
serializers: bunyan.stdSerializers,
level: bunyan.INFO,
});

const stage = process.env['stage'];
const webhookProvider = new S3WebhookConfigurationProvider(
log,
`${WEBHOOK_CONFIG_BUCKET}-${stage}-1`,
INTEGRATION_S3_KEY
);
const circuitBreakerProvider = new S3CircuitBreakerConfigurationProvider(
log,
`${FADE_RATE_BUCKET}-${stage}-1`,
FADE_RATE_S3_KEY
);
const fillerComplianceProvider = new S3FillerComplianceConfigurationProvider(
log,
`${COMPLIANCE_CONFIG_BUCKET}-${stage}-1`,
PROD_COMPLIANCE_S3_KEY
);
const repository = new MockFillerAddressRepository();
const firehose = new FirehoseLogger(log, process.env.ANALYTICS_STREAM_ARN!);
const quoters: Quoter[] = [
new WebhookQuoter(log, firehose, webhookProvider, circuitBreakerProvider, fillerComplianceProvider, repository),
];

return {
quoters: quoters,
firehose: firehose,
};
}

public async getRequestInjected(
_containerInjected: ContainerInjected,
requestBody: PostQuoteRequestBody,
_requestQueryParams: void,
_event: APIGatewayProxyEvent,
context: Context,
log: Logger,
metricsLogger: MetricsLogger
): Promise<RequestInjected> {
const requestId = context.awsRequestId;

log = log.child({
serializers: bunyan.stdSerializers,
requestBody,
requestId,
});
setGlobalLogger(log);
metricsLogger.setNamespace('Uniswap');
metricsLogger.setDimensions(UniswapXParamServiceIntegrationMetricDimension);
const metric = new AWSMetricsLogger(metricsLogger);
setGlobalMetric(metric);

return {
log,
metric,
requestId,
};
}
}
125 changes: 0 additions & 125 deletions lib/providers/circuit-breaker/s3.ts

This file was deleted.

Loading

0 comments on commit 042fdaf

Please sign in to comment.