Skip to content

Commit 51683fd

Browse files
docs: drop examples and clarify that data sent/received is identical
1 parent d8deec5 commit 51683fd

File tree

1 file changed

+3
-64
lines changed

1 file changed

+3
-64
lines changed

docs/how-tos/adding-event-bus-support-to-an-event.rst

Lines changed: 3 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -28,70 +28,7 @@ Step 2: Define the Event Payload
2828

2929
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.
3030

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-
class UserNonPersonalData:
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-
class UserPersonalData:
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-
class UserData(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-
class CourseData:
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.
9532

9633
The data types used in the attrs classes that the current Open edX Event Bus with the chosen schema are:
9734

@@ -113,6 +50,8 @@ Complex Data Types
11350

11451
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.
11552

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.
54+
11655
Step 3: Ensure Serialization and Deserialization
11756
------------------------------------------------
11857

0 commit comments

Comments
 (0)