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!: new event bus config format #272

Merged
merged 24 commits into from
Oct 6, 2023

Conversation

rgraber
Copy link
Contributor

@rgraber rgraber commented Sep 26, 2023

Description:
Change the event bus producing config from

{
    "event_type": [
        {topic: topic_a, event_key_field: field, enabled: True/False},
	{topic: topic_b, event_key_field: field, enabled: True/False},
    ]
}

to

{
     "event_type": {
         "topic_a":
	    {event_key_field: field, enabled: True/False},
	 "topic_b":
	    {event_key_field: field, enabled: True/False}
     }
}

ISSUE: #210

Dependencies: Would block openedx/edx-platform#33269

Reviewers:

  • tag reviewer
  • tag reviewer

Merge checklist:

  • All reviewers approved
  • CI build is green
  • Version bumped
  • Changelog record added
  • Documentation updated (not only docstrings)
  • Commits are squashed

Post merge:

  • Create a tag
  • Check new version is pushed to PyPI after tag-triggered build is
    finished.
  • Delete working branch (if not needed anymore)

Author concerns: List any concerns about this PR - inelegant
solutions, hacks, quick-and-dirty implementations, concerns about
migrations, etc.

@rgraber rgraber force-pushed the rsgraber/20230926-update-publish-via-config branch from f752ddc to d62ca05 Compare September 29, 2023 12:13
Copy link
Contributor

@robrap robrap left a comment

Choose a reason for hiding this comment

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

I did not do a full review (yet?), but just noting that the ADR looks good. Thanks.

@navinkarkera: [question] Can we get away with the backward incompatible change? That would be simplest, but I didn't know if we needed temporary code that transforms, or the use of a new name for the setting etc. for your transition? Or is that all for named releases and will it be simple to transition with instructions?

docs/decisions/0013-new-event-bus-producer-config.rst Outdated Show resolved Hide resolved
@bmtcril
Copy link
Contributor

bmtcril commented Sep 29, 2023

This all makes sense to me. Since the original PR never landed on edx-platform I don't think there's any reason for any special shims or error handling for the transition.

@navinkarkera
Copy link
Contributor

@robrap The original PR(s) using this config have not been merged yet, the one in edx-platform as well as openedx/xblock-skill-tagging#14. So we can go ahead with the backward incompatible change and update the PR's based on the decision and changes here.

Copy link
Contributor

@navinkarkera navinkarkera left a comment

Choose a reason for hiding this comment

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

@rgraber The ADR looks good to me. 👍

docs/decisions/0013-new-event-bus-producer-config.rst Outdated Show resolved Hide resolved
Copy link
Contributor

@robrap robrap left a comment

Choose a reason for hiding this comment

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

A left a bunch of mostly non-blocking suggestions. Also, any could be added as another iteration if we wish to improve and you want to land this more quickly.

CHANGELOG.rst Show resolved Hide resolved
openedx_events/apps.py Outdated Show resolved Hide resolved
openedx_events/apps.py Outdated Show resolved Hide resolved
openedx_events/event_bus/__init__.py Outdated Show resolved Hide resolved
openedx_events/tests/test_producer_config.py Outdated Show resolved Hide resolved
test_utils/test_settings.py Outdated Show resolved Hide resolved
raise ProducerConfigurationError(
event_type=event_type,
message="One of the configuration object is not a dictionary"
message="One of the configuration objects is not a dictionary"
Copy link
Contributor

Choose a reason for hiding this comment

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

Imagine everything is working fine, and someone adds a new bad config detail. Do we want that to break all working publishing? Seems scary. Something to consider.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point. I'm going to punt on this since it requires a little more thought than I want to put it while trying to land this but it will be a fast follow.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

[punt]

Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't it better to fail early rather than allowing a back config detail? This error will stop the application from starting.

@rgraber rgraber marked this pull request as ready for review October 5, 2023 12:41
@rgraber rgraber requested a review from a team as a code owner October 5, 2023 12:41
Copy link
Contributor

@robrap robrap left a comment

Choose a reason for hiding this comment

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

Thanks for the changes.

openedx_events/apps.py Outdated Show resolved Hide resolved
openedx_events/apps.py Outdated Show resolved Hide resolved
openedx_events/event_bus/__init__.py Outdated Show resolved Hide resolved
openedx_events/event_bus/__init__.py Outdated Show resolved Hide resolved
openedx_events/event_bus/__init__.py Outdated Show resolved Hide resolved
Copy link
Contributor

@robrap robrap left a comment

Choose a reason for hiding this comment

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

I think it is close.

openedx_events/event_bus/__init__.py Outdated Show resolved Hide resolved
Copy link
Contributor

@robrap robrap left a comment

Choose a reason for hiding this comment

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

Thank you.

Copy link
Contributor

@navinkarkera navinkarkera left a comment

Choose a reason for hiding this comment

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

@rgraber This looks great. Feel free to ignore my suggestions if it doesn't make sense.

Comment on lines +25 to +26
for topic in event_type_producer_configs.keys():
if event_type_producer_configs[topic]["enabled"] is True:
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
for topic in event_type_producer_configs.keys():
if event_type_producer_configs[topic]["enabled"] is True:
for topic, config in event_type_producer_configs.items():
if config["enabled"] is True:

topic=configuration["topic"],
event_key_field=configuration["event_key_field"],
topic=topic,
event_key_field=event_type_producer_configs[topic]["event_key_field"],
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
event_key_field=event_type_producer_configs[topic]["event_key_field"],
event_key_field=config["event_key_field"],

raise ProducerConfigurationError(
event_type=event_type,
message="One of the configuration object is not a dictionary"
message="One of the configuration objects is not a dictionary"
Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't it better to fail early rather than allowing a back config detail? This error will stop the application from starting.

@@ -183,3 +184,28 @@ def make_single_consumer(*, topic: str, group_id: str,
def _reset_state(sender, **kwargs): # pylint: disable=unused-argument
"""Reset caches when settings change during unit tests."""
get_producer.cache_clear()


def merge_producer_configs(producer_config_original, producer_config_overrides):
Copy link
Contributor

Choose a reason for hiding this comment

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

NIT: renaming these variables to original and overrides would make it easier to understand as producer_config prefix should not be needed.

@rgraber rgraber merged commit 6e7dbd2 into main Oct 6, 2023
8 checks passed
@rgraber rgraber deleted the rsgraber/20230926-update-publish-via-config branch October 6, 2023 16:22
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.

None yet

5 participants