Skip to content

Commit

Permalink
add alarm sns topic to infra local
Browse files Browse the repository at this point in the history
  • Loading branch information
baquan1708 committed Dec 20, 2024
1 parent 8221ade commit 4960765
Show file tree
Hide file tree
Showing 10 changed files with 29 additions and 8 deletions.
1 change: 1 addition & 0 deletions packages/cli/templates/.env.local
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ SFN_COMMAND_ARN=arn:aws:states:ap-northeast-1:101010101010:stateMachine:command
SNS_ENDPOINT=http://localhost:4002
SNS_REGION=ap-northeast-1
SNS_TOPIC_ARN=arn:aws:sns:ap-northeast-1:101010101010:CqrsSnsTopic
SNS_ALARM_TOPIC_ARN=arn:aws:sns:ap-northeast-1:101010101010:AlarmSnsTopic
# Cognito endpoint, useful for local development
COGNITO_URL=http://localhost:9229
COGNITO_USER_POOL_ID=local_2G7noHgW
Expand Down
5 changes: 5 additions & 0 deletions packages/cli/templates/infra-local/elasticmq.conf
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ queues {
delay = 5 seconds
receiveMessageWait = 0 seconds
}
alarm-queue {
defaultVisibilityTimeout = 60 seconds
delay = 5 seconds
receiveMessageWait = 0 seconds
}
}

aws {
Expand Down
4 changes: 4 additions & 0 deletions packages/cli/templates/infra-local/serverless.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ custom:
['notification-action', 'command-status', 'task-status'],
}
queue: http://localhost:9324/101010101010/notification-queue
- topic:
topicName: AlarmSnsTopic
rawMessageDelivery: 'true'
queue: http://localhost:9324/101010101010/alarm-queue
# host: 0.0.0.0 # Optional, defaults to 127.0.0.1 if not provided to serverless-offline
# sns-endpoint: http://127.0.0.1:4567 # Optional. Only if you want to use a custom SNS provider endpoint
# sns-subscribe-endpoint: http://127.0.0.1:3000 # Optional. Only if you want to use a custom subscribe endpoint from SNS to send messages back to
Expand Down
3 changes: 2 additions & 1 deletion packages/core/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ LOG_LEVEL=verbose # debug, verbose, info, warn, error, fatal
# disable event route for API GW integration
EVENT_SOURCE_DISABLED=false
# DynamoDB endpoint, useful for local development
DYNAMODB_ENDPOINT=http://0.0.0.0:8000
DYNAMODB_ENDPOINT=http://0.0.0.0:8000
DYNAMODB_REGION=ap-northeast-1
# set the limit size for `attributes` of object in DDB
ATTRIBUTE_LIMIT_SIZE=389120 # bytes, refer to https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/ServiceQuotas.html#limits-attributes
Expand All @@ -28,6 +28,7 @@ SFN_COMMAND_ARN=arn:aws:states:ap-northeast-1:101010101010:stateMachine:command
SNS_ENDPOINT=http://0.0.0.0:4002
SNS_REGION=ap-northeast-1
SNS_TOPIC_ARN=arn:aws:sns:ap-northeast-1:101010101010:CqrsSnsTopic
SNS_ALARM_TOPIC_ARN=arn:aws:sns:ap-northeast-1:101010101010:AlarmSnsTopic
# Cognito endpoint, useful for local development
COGNITO_URL=http://0.0.0.0:9229
COGNITO_USER_POOL_ID=local_2G7noHgW
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/commands/command.event.handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ export class CommandEventHandler {
event: DataSyncCommandSfnEvent,
errorDetails: any,
): Promise<void> {
this.logger.log('event', event)
this.logger.debug('event', event)
const alarm: INotification = {
action: 'sfn-alarm',
id: `${event.commandKey.pk}#${event.commandKey.sk}`,
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/commands/ttl.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export class TtlService implements ITtlService {
startDate?: Date,
): Promise<number | null> {
const numberOfDay = await this.getTtlConfiguration(type, tenantCode)
this.logger.log('numberOfDay', numberOfDay)
this.logger.debug('numberOfDay', numberOfDay)
return numberOfDay ? this.calculateUnixTime(numberOfDay, startDate) : null
}

Expand Down
5 changes: 5 additions & 0 deletions packages/core/test/infra-local/elasticmq.conf
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ queues {
delay = 5 seconds
receiveMessageWait = 0 seconds
}
alarm-queue {
defaultVisibilityTimeout = 60 seconds
delay = 5 seconds
receiveMessageWait = 0 seconds
}
}

aws {
Expand Down
5 changes: 5 additions & 0 deletions packages/core/test/infra-local/serverless.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ custom:
['notification-action', 'command-status', 'task-status'],
}
queue: http://localhost:9324/101010101010/notification-queue
- topic:
topicName: AlarmSnsTopic
rawMessageDelivery: 'true'
queue: http://localhost:9324/101010101010/alarm-queue
# host: 0.0.0.0 # Optional, defaults to 127.0.0.1 if not provided to serverless-offline
# sns-endpoint: http://127.0.0.1:4567 # Optional. Only if you want to use a custom SNS provider endpoint
# sns-subscribe-endpoint: http://127.0.0.1:3000 # Optional. Only if you want to use a custom subscribe endpoint from SNS to send messages back to
Expand Down Expand Up @@ -93,6 +97,7 @@ provider:
region: ap-northeast-1
runtime: nodejs18.x
profile: serverless
timeout: 100
httpApi:
authorizers:
localAuthorizer:
Expand Down
4 changes: 2 additions & 2 deletions packages/core/test/src/testing/handler/test-sync.handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ export class TestSyncHandler implements IDataSyncHandler {
private readonly logger = new Logger(TestSyncHandler.name)

async up(cmd: CommandModel): Promise<any> {
this.logger.log('TestSyncHandler.up', cmd)
this.logger.debug('TestSyncHandler.up', cmd)
}
async down(cmd: CommandModel): Promise<any> {
this.logger.log('TestSyncHandler.down', cmd)
this.logger.debug('TestSyncHandler.down', cmd)
}
}
6 changes: 3 additions & 3 deletions packages/sequence/src/sequences.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@ export class SequencesService implements ISequenceService {

const generalMasterPk = masterPk(tenantCode)
const generalMasterSk = `SEQ${KEY_SEPARATOR}${typeCode}`
this.logger.log('general master pk: ', generalMasterPk)
this.logger.log('general master sk: ', generalMasterSk)
this.logger.debug('general master pk: ', generalMasterPk)
this.logger.debug('general master sk: ', generalMasterSk)
const masterData = await this.masterDataProvider.getData({
pk: generalMasterPk,
sk: generalMasterSk,
Expand Down Expand Up @@ -288,7 +288,7 @@ export class SequencesService implements ISequenceService {

const effectiveStartMonth = registerTime
? registerTime.getMonth() + 1
: startMonth ?? 4
: (startMonth ?? 4)
const referenceYear = registerTime ? registerTime.getFullYear() : 1953 // Reference year

// Determine the current fiscal year
Expand Down

0 comments on commit 4960765

Please sign in to comment.