Skip to content

Commit

Permalink
Merge branch 'main' into LIVE-5319-bump-simple-configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
waisingyiu authored Nov 13, 2023
2 parents 7818140 + 5f913f3 commit 1afdb53
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 20 deletions.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @guardian/mss-admins
4 changes: 2 additions & 2 deletions notification/conf/notification.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ Resources:
Dimensions:
- Name: LoadBalancerName
Value: !Ref LoadBalancerToPrivateASG
EvaluationPeriods: 1
EvaluationPeriods: 10
MetricName: HTTPCode_Backend_5XX
Namespace: AWS/ELB
Period: 60
Expand All @@ -398,7 +398,7 @@ Resources:
Dimensions:
- Name: LoadBalancerName
Value: !Ref LoadBalancerToPrivateASG
EvaluationPeriods: 1
EvaluationPeriods: 10
MetricName: HTTPCode_ELB_5XX
Namespace: AWS/ELB
Period: 60
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`The MobileAppsRendering stack matches the snapshot 1`] = `
exports[`The Sender Worker stack matches the snapshot 1`] = `
Object {
"Metadata": Object {
"gu:cdk:constructs": Array [],
Expand Down Expand Up @@ -512,7 +512,7 @@ Object {
},
"androidSenderTooFewInvocationsAlarmC306ECD5": Object {
"Properties": Object {
"ActionsEnabled": false,
"ActionsEnabled": true,
"AlarmActions": Array [
Object {
"Ref": "AlarmTopicArn",
Expand All @@ -536,7 +536,7 @@ Object {
"Ref": "AlarmTopicArn",
},
],
"Period": 360,
"Period": 3600,
"Statistic": "Sum",
"Threshold": 0,
"TreatMissingData": "breaching",
Expand Down Expand Up @@ -982,7 +982,7 @@ Object {
},
"androidbetaSenderTooFewInvocationsAlarm7B50CD4B": Object {
"Properties": Object {
"ActionsEnabled": false,
"ActionsEnabled": true,
"AlarmActions": Array [
Object {
"Ref": "AlarmTopicArn",
Expand All @@ -1006,7 +1006,7 @@ Object {
"Ref": "AlarmTopicArn",
},
],
"Period": 360,
"Period": 3600,
"Statistic": "Sum",
"Threshold": 0,
"TreatMissingData": "breaching",
Expand Down Expand Up @@ -1452,7 +1452,7 @@ Object {
},
"androideditionSenderTooFewInvocationsAlarmE4AB00FB": Object {
"Properties": Object {
"ActionsEnabled": false,
"ActionsEnabled": true,
"AlarmActions": Array [
Object {
"Ref": "AlarmTopicArn",
Expand All @@ -1476,7 +1476,7 @@ Object {
"Ref": "AlarmTopicArn",
},
],
"Period": 360,
"Period": 86400,
"Statistic": "Sum",
"Threshold": 0,
"TreatMissingData": "breaching",
Expand Down Expand Up @@ -1922,7 +1922,7 @@ Object {
},
"iosSenderTooFewInvocationsAlarm14117FE9": Object {
"Properties": Object {
"ActionsEnabled": false,
"ActionsEnabled": true,
"AlarmActions": Array [
Object {
"Ref": "AlarmTopicArn",
Expand All @@ -1946,7 +1946,7 @@ Object {
"Ref": "AlarmTopicArn",
},
],
"Period": 360,
"Period": 3600,
"Statistic": "Sum",
"Threshold": 0,
"TreatMissingData": "breaching",
Expand Down Expand Up @@ -2392,7 +2392,7 @@ Object {
},
"ioseditionSenderTooFewInvocationsAlarmD32BB28C": Object {
"Properties": Object {
"ActionsEnabled": false,
"ActionsEnabled": true,
"AlarmActions": Array [
Object {
"Ref": "AlarmTopicArn",
Expand All @@ -2416,7 +2416,7 @@ Object {
"Ref": "AlarmTopicArn",
},
],
"Period": 360,
"Period": 86400,
"Statistic": "Sum",
"Threshold": 0,
"TreatMissingData": "breaching",
Expand Down
2 changes: 1 addition & 1 deletion notificationworkerlambda/cdk/lib/senderworker.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Template } from "aws-cdk-lib/assertions";
import { App } from "aws-cdk-lib"
import {SenderWorkerStack} from "./senderworker";

describe('The MobileAppsRendering stack', () => {
describe('The Sender Worker stack', () => {
it('matches the snapshot', () => {
const app = new App();
const stack = new SenderWorkerStack(app, 'SenderWorkerStack', {
Expand Down
17 changes: 11 additions & 6 deletions notificationworkerlambda/cdk/lib/senderworker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ interface SenderWorkerOpts {
platform: string,
paramPrefix: string,
isBatchingSqsMessages: boolean,
dailyAlarmPeriod: boolean
}

class SenderWorker extends cdkcore.Construct {
Expand Down Expand Up @@ -152,9 +153,10 @@ class SenderWorker extends cdkcore.Construct {
comparisonOperator: cloudwatch.ComparisonOperator.LESS_THAN_OR_EQUAL_TO_THRESHOLD,
evaluationPeriods: 1,
threshold: 0,
metric: senderLambdaCtr.metricInvocations({period: cdk.Duration.seconds(360), statistic: "Sum"}),
// whole day for editions, 60 minutes for others
metric: senderLambdaCtr.metricInvocations({period: cdk.Duration.seconds(props.dailyAlarmPeriod ? 60 * 60 * 24 : 60 * 60), statistic: "Sum"}),
treatMissingData: cloudwatch.TreatMissingData.BREACHING,
actionsEnabled: false // isEnabled
actionsEnabled: true // isEnabled
})
senderTooFewInvocationsAlarm.addAlarmAction(snsTopicAction)
senderTooFewInvocationsAlarm.addOkAction(snsTopicAction)
Expand Down Expand Up @@ -217,14 +219,15 @@ export class SenderWorkerStack extends GuStack {

let workerQueueArns: string[] = []

const addWorker = (workerName: string, paramPrefix: string, handler: string, isBatchingSqsMessages: boolean = false) => {
const addWorker = (workerName: string, paramPrefix: string, handler: string, isBatchingSqsMessages: boolean = false, dailyAlarmPeriod: boolean = false) => {
let worker = new SenderWorker(this, workerName, {
...props,
platform: workerName,
paramPrefix: paramPrefix,
handler: handler,
isBatchingSqsMessages,
...sharedOpts
...sharedOpts,
dailyAlarmPeriod: dailyAlarmPeriod
})
workerQueueArns.push(worker.senderSqs.queueArn)
}
Expand All @@ -236,8 +239,10 @@ export class SenderWorkerStack extends GuStack {

addWorker("ios", "iosLive", "com.gu.notifications.worker.IOSSender::handleChunkTokens")
addWorker("android", "androidLive", "com.gu.notifications.worker.AndroidSender::handleChunkTokens", true)
addWorker("ios-edition", "iosEdition", "com.gu.notifications.worker.IOSSender::handleChunkTokens")
addWorker("android-edition", "androidEdition", "com.gu.notifications.worker.AndroidSender::handleChunkTokens")
// edition apps only send one notification a day in order to get content for that day
addWorker("ios-edition", "iosEdition", "com.gu.notifications.worker.IOSSender::handleChunkTokens", false, true)
addWorker("android-edition", "androidEdition", "com.gu.notifications.worker.AndroidSender::handleChunkTokens", false, true)

addWorker("android-beta", "androidBeta", "com.gu.notifications.worker.AndroidSender::handleChunkTokens")

/*
Expand Down

0 comments on commit 1afdb53

Please sign in to comment.