You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/how-tos/adding-event-bus-support-to-an-event.rst
+3-64Lines changed: 3 additions & 64 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -28,70 +28,7 @@ Step 2: Define the Event Payload
28
28
29
29
An Open edX Event is compatible with the event bus when its payload can be serialized, sent, and deserialized by other services. The payload, structured as `attrs data classes`_, must align with the event bus schema format which in this case is the :term:`Avro Schema`. This schema is used to serialize and deserialize the :term:`Event Payload` when sending it across services.
30
30
31
-
This ensures the event can be sent by the producer and be then re-emitted by the same instance of `OpenEdxPublicSignal`_ on the consumer side. For more information on the event bus schema format, refer to the :doc:`../decisions/0004-external-event-bus-and-django-signal-events` and :doc:`../decisions/0005-external-event-schema-format` decision records.
32
-
33
-
Here is an example of an :term:`Event Payload` structured as `attrs data classes`_ that align with the event bus schema format:
34
-
35
-
.. code-block:: python
36
-
37
-
@attr.s(frozen=True)
38
-
classUserNonPersonalData:
39
-
"""
40
-
Attributes defined for Open edX user object based on non-PII data.
41
-
42
-
Arguments:
43
-
id (int): unique identifier for the Django User object.
44
-
is_active (bool): indicates whether the user is active.
45
-
"""
46
-
47
-
id= attr.ib(type=int)
48
-
is_active = attr.ib(type=bool)
49
-
50
-
@attr.s(frozen=True)
51
-
classUserPersonalData:
52
-
"""
53
-
Attributes defined for Open edX user object based on PII data.
54
-
55
-
Arguments:
56
-
username (str): username associated with the Open edX user.
57
-
email (str): email associated with the Open edX user.
58
-
name (str): name associated with the Open edX user's profile.
59
-
"""
60
-
61
-
username = attr.ib(type=str)
62
-
email = attr.ib(type=str)
63
-
name = attr.ib(type=str, factory=str)
64
-
65
-
@attr.s(frozen=True)
66
-
classUserData(UserNonPersonalData):
67
-
"""
68
-
Attributes defined for Open edX user object.
69
-
70
-
This class extends UserNonPersonalData to include PII data completing the
71
-
user object.
72
-
73
-
Arguments:
74
-
pii (UserPersonalData): user's Personal Identifiable Information.
75
-
"""
76
-
77
-
pii = attr.ib(type=UserPersonalData)
78
-
79
-
@attr.s(frozen=True)
80
-
classCourseData:
81
-
"""
82
-
Attributes defined for Open edX Course Overview object.
83
-
84
-
Arguments:
85
-
course_key (str): identifier of the Course object.
86
-
display_name (str): display name associated with the course.
87
-
start (datetime): start date for the course.
88
-
end (datetime): end date for the course.
89
-
"""
90
-
91
-
course_key = attr.ib(type=CourseKey)
92
-
display_name = attr.ib(type=str, factory=str)
93
-
start = attr.ib(type=datetime, default=None)
94
-
end = attr.ib(type=datetime, default=None)
31
+
This ensures the event can be sent by the producer and be then re-emitted by the same instance of `OpenEdxPublicSignal`_ on the consumer side, guaranteeing that the data sent and received is the identical. Serializing this way should prevent data inconsistencies between services, e.g., timezone issues and precision loss. For more information on the event bus schema format, refer to the :doc:`../decisions/0004-external-event-bus-and-django-signal-events` and :doc:`../decisions/0005-external-event-schema-format` decision records.
95
32
96
33
The data types used in the attrs classes that the current Open edX Event Bus with the chosen schema are:
97
34
@@ -113,6 +50,8 @@ Complex Data Types
113
50
114
51
Ensure that the :term:`Event Payload` is structured as `attrs data classes`_ and that the data types used in those classes align with the event bus schema format.
115
52
53
+
In the ``data.py`` files within each architectural subdomain you can find examples of the :term:`Event Payload` structured as `attrs data classes`_ that align with the event bus schema format.
0 commit comments