-
Notifications
You must be signed in to change notification settings - Fork 2
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(dynamo db): integrate with dynamo db #770
feat(dynamo db): integrate with dynamo db #770
Conversation
return this.dynamoDBClient.getItem(this.TABLE_NAME, MOCK_LAUNCH.appId) | ||
} | ||
async getAllSuccessOrFailureLaunches(): Promise<SiteLaunchMessage[]> { | ||
const entries = ((await this.dynamoDBClient.getAllItems(this.TABLE_NAME)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how do we replicate this behaviour (or if difficult, could you just attach an ss of the stringified Item
itself so that we can see in entirety the properties)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have updated the PR desc to include the steps, but the TLDR when logging the result over is:
For context, we should instead expect an object of a shape something similar to this:
{
"appId": {
"S": "my-app"
},
"agencyEmail": {
"S": "[email protected]"
},
"domainValidationSource": {
"S": "example.com"
},
"domainValidationTarget": {
"S": "myapp.example.com"
},
"githubRedirectionUrl": {
"S": "https://github.com/my-repo"
},
"primaryDomainSource": {
"S": "example.com"
},
"primaryDomainTarget": {
"S": "myapp.example.com"
},
"PRIMARY_KEY": {
"S": "my-app"
},
"redirectionDomain": {
"L": [
{
"M": {
"source": {
"S": "example.com"
},
"target": {
"S": "myapp.example.com"
},
"type": {
"S": "A"
}
}
}
]
},
"repoName": {
"S": "my-repo"
},
"requestorEmail": {
"S": "[email protected]"
},
"status": {
"M": {
"message": {
"S": "PENDING_DURING_SITE_LAUNCH"
},
"state": {
"S": "pending"
}
}
}
}
7acaebe
to
b109eed
Compare
src/services/infra/InfraService.ts
Outdated
@@ -52,6 +54,7 @@ type CreateSiteParams = { | |||
isEmailLogin: boolean | |||
} | |||
|
|||
const ARE_QUEUES_DEPRECIATED = false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if this is meant for feature flagging, then it should be an env var. this is because setting this to true
still involves a code deployment to our backend (during which we might as well just change the actual code).
changing it to env vars allows us to deploy the required code without an associated code change (ie, we can deploy first and delete later)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes that's right. Feature flags modifications shouldn't require a full re-deploy. Hence it shld be in the env vars
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, modified to use env vars instead here faed0d0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shall we impose a standard to prefix all feature flags with a FF_ARE_QUEUES_DEPRECATED?
This will allow us to quickly understand an env var is a feature flag toggle
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: the flag should be something like a verb instead of a question
like DISABLE_SITE_LAUNCH_QUEUES
or DEPRECATE_SITE_QUEUES
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
src/services/infra/InfraService.ts
Outdated
@@ -387,7 +404,9 @@ export default class InfraService { | |||
} | |||
|
|||
siteUpdate = async () => { | |||
const messages = await this.queueService.pollMessages() | |||
const messages = DEPRECATE_SITE_QUEUES | |||
? await this.dynamoDBService.getAllCompletedLaunches() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if any of this throws, are the errors caught appropriately?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
using a trivial try-catch wrapper here. Understand that we have an error handling portion to standardise the error formatting, will modify that when the scaffolding work for the error formatting is up! 0fa7912
private client: StepFunctions | ||
|
||
constructor(private stateMachineArn: string) { | ||
this.client = new StepFunctions({ region: "ap-southeast-1" }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should the region come from env vars?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, modified here ca073d1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@harishv7 out of curiosity - why inject it from env vars? my understanding is that it's a constant (as we aren't gonna change region
) so i'd be more inclined to export it from a constants
file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@seaerchin I am fine with a constants file too. I suggested env vars, because we are building this open source, for people to try this, they would need to know exactly what are the config they need to provide. Which would be better to come from an env-var or an explicit config.js
file
@seaerchin Hey, let me know if you have any concerns regarding this PR via slack, happy to discuss / create new tickets if needed! |
Problem
This is the first PR in the effort to remove the usage of queues in our backend.
Doesn't fully close IS-186, but am putting a feature flag in the spirit of merging some work into prod first.
Solution
The flag
ARE_QUEUES_DEPRECIATED
inInfraService.ts
will determine whether or not to use the existing queues or use the dynamodbs vs queues for the site launch process. Idea is after the integration work in the infra side + enough testing, we can swap swap the value of the flag for one site launch process, and then if there are no issues for a while in production, we can remove this feature flag + queues related code altogether.Breaking Changes
Reviewer Notes
I am not sure if its only me but the typing given in the AWS SDK for dynamo DB is abit off ._.
I have given a screenshot in the related comment below + added test cases to explicitly codify the expected behaviour that we expect from the
dynamoDBDocClient.send(new ScanCommand(params))
call. Open to feedback on this.Steps to replicate the error thrown by ts
server.js
:Note that the returned object is not of the declared type
Record<string, AttributeValue>[] | undefined
New environment variables:
STEP_FUNCTIONS_ARN
: arn for step functions //todo add in 1pw post-approval of this PRTests
added a file
DynamoDBService.spec.ts
for tests