-
Notifications
You must be signed in to change notification settings - Fork 21
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: use new setting to set ce_source #305
Merged
Merged
Changes from 13 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
9faab6b
feat: another setting for source in EventsMetadata
9b7713f
fixup!: version
1c4b2bb
fixup!: default
b90d61c
fixup!: unpack
5829550
fixup!: oops
db3e34e
fixup!: quality
fa01834
fixup!: docdocdoc
ba48114
fixup!: fix name
805109b
fixup!: fix test
34f2300
fixup!: Apply suggestions from code review
76f7ab7
fixup!: keep renaming
f208269
fixup!: fix log
847ff73
fixup!: SSSS
ac30fb1
fixup!: comments from review
9ae0dd8
fixup!: fix test
2ac9491
fixup!: quality
8dd3bb6
fixup!: docstrings
3b7dac4
fixup!: documentation + tweaks
9a1a445
fixup!: documentation
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,4 +5,4 @@ | |
more information about the project. | ||
""" | ||
|
||
__version__ = "9.2.0" | ||
__version__ = "9.3.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,6 +27,19 @@ def _ensure_utc_time(_, attribute, value): | |
raise ValueError(f"'{attribute.name}' must have timezone.utc") | ||
|
||
|
||
def get_source_name(): | ||
""" | ||
Get the value that should be used for the source of an event. | ||
""" | ||
# .. setting_name: EVENTS_SERVICE_NAME | ||
# .. setting_default: None | ||
# .. setting_description: Identifier for the producing/consuming service of an event. Used in setting the source in | ||
# the EventsMetadata. If not set, the EventsMetadata object will look for a SERVICE_VARIANT setting (usually only | ||
# set for lms and cms). The full source will be set to openedx/<EVENTS_SERVICE_NAME or SERVICE_VARIANT>/web. | ||
# If neither variable is set, the source will be "unidentified." | ||
return getattr(settings, "EVENTS_SERVICE_NAME", None) or getattr(settings, "SERVICE_VARIANT", None) | ||
|
||
|
||
@attr.s(frozen=True) | ||
class EventsMetadata: | ||
""" | ||
|
@@ -62,7 +75,8 @@ class EventsMetadata: | |
source = attr.ib( | ||
type=str, default=None, | ||
converter=attr.converters.default_if_none( | ||
attr.Factory(lambda: "openedx/{service}/web".format(service=getattr(settings, "SERVICE_VARIANT", ""))) | ||
attr.Factory(lambda: "openedx/{service}/web".format(service=get_source_name()) if get_source_name() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. NIt:
|
||
else "unidentified") | ||
), | ||
validator=attr.validators.instance_of(str), | ||
) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back 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.
get_service_name
._get_service_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.
Also note that if this function were private, and just used for this one purpose, it could return
SERVICE-NAME-UNSET
itself in place of None.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.
I wanted to call it from event bus kafka
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.
It should still be changed to
get_service_name
though, right?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.
It was. I have 2 methods now