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

moving publish action into a lambda #296

Merged
merged 5 commits into from
Apr 25, 2024

Conversation

GavCookCO
Copy link
Contributor

Description

moved the request to pblish to open search out of our application and into am SQS queue and a lambda.

Ticket # and link

Summary of the changes and the related issue. List any dependencies that are required for this change:

Type of change

Please check the relevant options.

  • Bug fix (non-breaking change which fixes an issue).
  • New feature (non-breaking change which adds functionality).
  • Breaking change (fix or feature that would cause existing functionality to not work as expected).
  • This change requires a documentation update.

How Has This Been Tested?

Please describe the tests that you ran to verify your changes:

  • Unit Test

  • Integration Test (if applicable)

  • End-to-End Test (if applicable)

Screenshots (if appropriate):

Please attach screenshots of the change if it is a UI change:

Checklist:

  • If I have listed dependencies above, I have ensured that they are present in the target branch.
  • I have performed a self-review of my code.
  • I have commented my code in hard-to-understand areas.
  • I have made corresponding changes to the documentation where applicable.
  • I have run cypress tests, and they all pass locally.

@@ -320,7 +326,7 @@ public GrantAdvert publishAdvert(UUID advertId) {

if (Boolean.FALSE.equals(contentfulAdvert.isPublished())) {
final CMAEntry publishedAdvert = contentfulManagementClient.entries().publish(contentfulAdvert);
openSearchService.indexEntry(publishedAdvert);
sendMessageToQueue(new SendAdvertToSqsDto(publishedAdvert.getId(), "ADD"));
Copy link
Contributor

@dominicwest dominicwest Apr 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this function should be the very last thing this endpoint does - as if we fail to save to the DB for whatever reason upon a scheduled publishing, this endpoint will be hit multiple times due to the publish advert lambdas retry behaviour, which will result in us sending multiple messages to our new publish elastic lambda.

I think the end state would then be duplicate adverts showing up in elastic in this edge case, which would require manually cleaning up

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Jamie and I tested elastic last week, it's idempotent so not sure there would be duplicates but the lambda on the other end of this exchange might end up with errors from contentful so good shout nonetheless.

@@ -333,7 +339,7 @@ public void unpublishAdvert(UUID advertId) {

if (Boolean.TRUE.equals(contentfulAdvert.isPublished())) {
final CMAEntry unpublishedAd = contentfulManagementClient.entries().unPublish(contentfulAdvert);
openSearchService.removeIndexEntry(unpublishedAd);
sendMessageToQueue(new SendAdvertToSqsDto(unpublishedAd.getId(), "REMOVE"));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

@GavCookCO GavCookCO merged commit 1b2b9f3 into develop Apr 25, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants