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

feat: adding event bus functionality #1848

Closed
wants to merge 3 commits into from
Closed

Conversation

kiram15
Copy link
Contributor

@kiram15 kiram15 commented Aug 17, 2023

Adding event bus producer functionality to unenrollment event.
https://2u-internal.atlassian.net/browse/ENT-7560

Merge checklist:

  • Any new requirements are in the right place (do not manually modify the requirements/*.txt files)
    • base.in if needed in production but edx-platform doesn't install it
    • test-master.in if edx-platform pins it, with a matching version
    • make upgrade && make requirements have been run to regenerate requirements
  • make static has been run to update webpack bundling if any static content was updated
  • ./manage.py makemigrations has been run
    • Checkout the Database Migration Confluence page for helpful tips on creating migrations.
    • Note: This must be run if you modified any models.
      • It may or may not make a migration depending on exactly what you modified, but it should still be run.
    • This should be run from either a venv with all the lms/edx-enterprise requirements installed or if you checked out edx-enterprise into the src directory used by lms, you can run this command through an lms shell.
      • It would be ./manage.py lms makemigrations in the shell.
  • Version bumped
  • Changelog record added
  • Translations updated (see docs/internationalization.rst but also this isn't blocking for merge atm)

Post merge:

  • Tag pushed and a new version released
    • Note: Assets will be added automatically. You just need to provide a tag (should match your version number) and title and description.
  • After versioned build finishes in GitHub Actions, verify version has been pushed to PyPI
    • Each step in the release build has a condition flag that checks if the rest of the steps are done and if so will deploy to PyPi.
      (so basically once your build finishes, after maybe a minute you should see the new version in PyPi automatically (on refresh))
  • PR created in edx-platform to upgrade dependencies (including edx-enterprise)
    • This must be done after the version is visible in PyPi as make upgrade in edx-platform will look for the latest version in PyPi.
    • Note: the edx-enterprise constraint in edx-platform must also be bumped to the latest version in PyPi.

@kiram15 kiram15 requested review from a team and justinhynes August 18, 2023 15:30
)
enterprise_enrollment.unenrolled_at = localized_utcnow()
enterprise_enrollment.save()
get_producer().send(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Does this need to be gated behind a feature_flag?

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think it's a hard requirement but a best practice. It makes sense to have a feature flag in edx-platform or Credentials as there is likely going to be some time before the event bus is widely adopted by the Open edX Community. Relevant link to docs: https://openedx.atlassian.net/wiki/spaces/AC/pages/3508699151/How+to+start+using+the+Event+Bus#Producing

If there are any consumers of edx-enterprise outside of edx.org/2U, I would say it's a necessity. At the least, a temporary one is good in case we need to disable the functionality without a revert/code release.

)
enterprise_enrollment.unenrolled_at = localized_utcnow()
enterprise_enrollment.save()
get_producer().send(
signal=COURSE_UNENROLLMENT_COMPLETED,
Copy link
Contributor

Choose a reason for hiding this comment

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

this is a generic unenrollment signal but you only fire it for enterprise enrollments - i'd probably produce an event for all of these signals, not just the enterprise ones. i think this event is emitted somewhere upstream and that is where we should put that signal on the bus

)
enterprise_enrollment.unenrolled_at = localized_utcnow()
enterprise_enrollment.save()
get_producer().send(
signal=COURSE_UNENROLLMENT_COMPLETED,
topic='course-unenrollment-completed',
Copy link
Contributor

Choose a reason for hiding this comment

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

did you look into using a topic like 'course-enrollment-lifecycle'?

Copy link
Contributor

@justinhynes justinhynes Aug 21, 2023

Choose a reason for hiding this comment

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

FWIW, my understanding is the topics that are named with "{blah]-lifecycle" are when a topic handles multiple distinct events in a single topic.

The {environment}-learning-certificate-lifecycle events receive the "certificate awarded" and "certificate revoked" events.

@kiram15 -- One thing I will note, another best practice is that the name of the topic should contain the architecture subdomain the event belongs to. In this case, it is the learning subdomain. Whatever this topic name ends up being, it should include this subdomain (e.g. learning-{topic_name}).

)
enterprise_enrollment.unenrolled_at = localized_utcnow()
enterprise_enrollment.save()
get_producer().send(
signal=COURSE_UNENROLLMENT_COMPLETED,
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we check if COUSE_ENROLLMENT_COMPLETED is not None before using it? It looks like it can potentially be None depending on if there was an ImportError.

Copy link
Contributor Author

@kiram15 kiram15 Aug 22, 2023

Choose a reason for hiding this comment

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

The reason I didn't put the check on it was later on in the code (line 410), we have a check that doesn't connect the receiver unless it is not None. I can put another check in if this is not sufficient though, but this seems to do it already.

if COURSE_UNENROLLMENT_COMPLETED is not None: COURSE_UNENROLLMENT_COMPLETED.connect(enterprise_unenrollment_receiver)

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