From 9a6702034ce18c4df9ae03399bdef609cff36d75 Mon Sep 17 00:00:00 2001 From: Navin Karkera Date: Thu, 10 Oct 2024 12:22:59 +0530 Subject: [PATCH 1/3] refactor: add lazy field to LibraryCollectionData This is required to handle the signal asynchronously whenever the sender does not care about the handler execution completion. For example, whenever multiple collections are updated due to a component being added or removed, we do not want to wait for all collection update handlers to complete. --- openedx_events/content_authoring/data.py | 3 +++ ...horing+content_library+collection+created+v1_schema.avsc | 6 +++++- ...horing+content_library+collection+deleted+v1_schema.avsc | 6 +++++- ...horing+content_library+collection+updated+v1_schema.avsc | 6 +++++- 4 files changed, 18 insertions(+), 3 deletions(-) diff --git a/openedx_events/content_authoring/data.py b/openedx_events/content_authoring/data.py index 4e76bcd7..268812d2 100644 --- a/openedx_events/content_authoring/data.py +++ b/openedx_events/content_authoring/data.py @@ -221,7 +221,10 @@ class LibraryCollectionData: Arguments: library_key (LibraryLocatorV2): a key that represents a Blockstore-based content library. collection_key (str): identifies the collection within the library's learning package + lazy (bool): indicate whether the sender doesn't want to wait for handler to finish execution, + i.e., the handler can run the task in background. By default it is False. """ library_key = attr.ib(type=LibraryLocatorV2) collection_key = attr.ib(type=str) + lazy = attr.ib(type=bool, default=False) diff --git a/openedx_events/event_bus/avro/tests/schemas/org+openedx+content_authoring+content_library+collection+created+v1_schema.avsc b/openedx_events/event_bus/avro/tests/schemas/org+openedx+content_authoring+content_library+collection+created+v1_schema.avsc index 58b77a50..81f87cc7 100644 --- a/openedx_events/event_bus/avro/tests/schemas/org+openedx+content_authoring+content_library+collection+created+v1_schema.avsc +++ b/openedx_events/event_bus/avro/tests/schemas/org+openedx+content_authoring+content_library+collection+created+v1_schema.avsc @@ -16,10 +16,14 @@ { "name": "collection_key", "type": "string" + }, + { + "name": "lazy", + "type": "boolean" } ] } } ], "namespace": "org.openedx.content_authoring.content_library.collection.created.v1" -} \ No newline at end of file +} diff --git a/openedx_events/event_bus/avro/tests/schemas/org+openedx+content_authoring+content_library+collection+deleted+v1_schema.avsc b/openedx_events/event_bus/avro/tests/schemas/org+openedx+content_authoring+content_library+collection+deleted+v1_schema.avsc index 473d4163..1c2628e5 100644 --- a/openedx_events/event_bus/avro/tests/schemas/org+openedx+content_authoring+content_library+collection+deleted+v1_schema.avsc +++ b/openedx_events/event_bus/avro/tests/schemas/org+openedx+content_authoring+content_library+collection+deleted+v1_schema.avsc @@ -16,10 +16,14 @@ { "name": "collection_key", "type": "string" + }, + { + "name": "lazy", + "type": "boolean" } ] } } ], "namespace": "org.openedx.content_authoring.content_library.collection.deleted.v1" -} \ No newline at end of file +} diff --git a/openedx_events/event_bus/avro/tests/schemas/org+openedx+content_authoring+content_library+collection+updated+v1_schema.avsc b/openedx_events/event_bus/avro/tests/schemas/org+openedx+content_authoring+content_library+collection+updated+v1_schema.avsc index 54733048..8a3b583a 100644 --- a/openedx_events/event_bus/avro/tests/schemas/org+openedx+content_authoring+content_library+collection+updated+v1_schema.avsc +++ b/openedx_events/event_bus/avro/tests/schemas/org+openedx+content_authoring+content_library+collection+updated+v1_schema.avsc @@ -16,10 +16,14 @@ { "name": "collection_key", "type": "string" + }, + { + "name": "lazy", + "type": "boolean" } ] } } ], "namespace": "org.openedx.content_authoring.content_library.collection.updated.v1" -} \ No newline at end of file +} From 624a8924974a66fc3d4e0cd6bd7eb0d4c141ead9 Mon Sep 17 00:00:00 2001 From: Navin Karkera Date: Thu, 10 Oct 2024 12:51:02 +0530 Subject: [PATCH 2/3] chore: bump version and update changelog --- CHANGELOG.rst | 8 ++++++++ openedx_events/__init__.py | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 81f6cab3..517d8725 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -18,6 +18,14 @@ __________ +[9.15.0] - 2024-10-10 +--------------------- + +Changed +~~~~~~~ + +* Added ``lazy`` field to ``LibraryCollectionData`` so that senders can specify if handlers can run asynchrounously. + [9.14.1] - 2024-09-17 --------------------- diff --git a/openedx_events/__init__.py b/openedx_events/__init__.py index 734bf9c6..bd096725 100644 --- a/openedx_events/__init__.py +++ b/openedx_events/__init__.py @@ -5,4 +5,4 @@ more information about the project. """ -__version__ = "9.14.1" +__version__ = "9.15.0" From fc40c029dbb28f185b1adf652f0536335c489123 Mon Sep 17 00:00:00 2001 From: Navin Karkera Date: Fri, 11 Oct 2024 17:15:49 +0530 Subject: [PATCH 3/3] refactor: rename lazy to background --- CHANGELOG.rst | 2 +- openedx_events/content_authoring/data.py | 4 ++-- ...uthoring+content_library+collection+created+v1_schema.avsc | 2 +- ...uthoring+content_library+collection+deleted+v1_schema.avsc | 2 +- ...uthoring+content_library+collection+updated+v1_schema.avsc | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 517d8725..bb1f1d4b 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -24,7 +24,7 @@ __________ Changed ~~~~~~~ -* Added ``lazy`` field to ``LibraryCollectionData`` so that senders can specify if handlers can run asynchrounously. +* Added ``background`` field to ``LibraryCollectionData`` so that senders can specify if handlers can run asynchrounously. [9.14.1] - 2024-09-17 --------------------- diff --git a/openedx_events/content_authoring/data.py b/openedx_events/content_authoring/data.py index 268812d2..e5d376fb 100644 --- a/openedx_events/content_authoring/data.py +++ b/openedx_events/content_authoring/data.py @@ -221,10 +221,10 @@ class LibraryCollectionData: Arguments: library_key (LibraryLocatorV2): a key that represents a Blockstore-based content library. collection_key (str): identifies the collection within the library's learning package - lazy (bool): indicate whether the sender doesn't want to wait for handler to finish execution, + background (bool): indicate whether the sender doesn't want to wait for handler to finish execution, i.e., the handler can run the task in background. By default it is False. """ library_key = attr.ib(type=LibraryLocatorV2) collection_key = attr.ib(type=str) - lazy = attr.ib(type=bool, default=False) + background = attr.ib(type=bool, default=False) diff --git a/openedx_events/event_bus/avro/tests/schemas/org+openedx+content_authoring+content_library+collection+created+v1_schema.avsc b/openedx_events/event_bus/avro/tests/schemas/org+openedx+content_authoring+content_library+collection+created+v1_schema.avsc index 81f87cc7..0c47f299 100644 --- a/openedx_events/event_bus/avro/tests/schemas/org+openedx+content_authoring+content_library+collection+created+v1_schema.avsc +++ b/openedx_events/event_bus/avro/tests/schemas/org+openedx+content_authoring+content_library+collection+created+v1_schema.avsc @@ -18,7 +18,7 @@ "type": "string" }, { - "name": "lazy", + "name": "background", "type": "boolean" } ] diff --git a/openedx_events/event_bus/avro/tests/schemas/org+openedx+content_authoring+content_library+collection+deleted+v1_schema.avsc b/openedx_events/event_bus/avro/tests/schemas/org+openedx+content_authoring+content_library+collection+deleted+v1_schema.avsc index 1c2628e5..da95e9e0 100644 --- a/openedx_events/event_bus/avro/tests/schemas/org+openedx+content_authoring+content_library+collection+deleted+v1_schema.avsc +++ b/openedx_events/event_bus/avro/tests/schemas/org+openedx+content_authoring+content_library+collection+deleted+v1_schema.avsc @@ -18,7 +18,7 @@ "type": "string" }, { - "name": "lazy", + "name": "background", "type": "boolean" } ] diff --git a/openedx_events/event_bus/avro/tests/schemas/org+openedx+content_authoring+content_library+collection+updated+v1_schema.avsc b/openedx_events/event_bus/avro/tests/schemas/org+openedx+content_authoring+content_library+collection+updated+v1_schema.avsc index 8a3b583a..7f581cd5 100644 --- a/openedx_events/event_bus/avro/tests/schemas/org+openedx+content_authoring+content_library+collection+updated+v1_schema.avsc +++ b/openedx_events/event_bus/avro/tests/schemas/org+openedx+content_authoring+content_library+collection+updated+v1_schema.avsc @@ -18,7 +18,7 @@ "type": "string" }, { - "name": "lazy", + "name": "background", "type": "boolean" } ]