-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor!: Move to new package structure to highlight public/internal…
… distinction (#37) Document the public API in the README; add ADR to explain refactor. Also: - Fix some rST syntax in the changelog; fix a release heading - Add another missing `__init__.py` file (and fix lint exposed by that) - Small test improvement while I'm in there - Remove redundant consumer README (duplicated by main README)
- Loading branch information
Showing
18 changed files
with
99 additions
and
28 deletions.
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
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 |
---|---|---|
@@ -0,0 +1,47 @@ | ||
6. Public API and App Organization | ||
################################## | ||
|
||
|
||
Status | ||
****** | ||
|
||
Accepted | ||
|
||
Context | ||
******* | ||
|
||
There has been no clear distinction between the public API in this package and the various internal, subject-to-change module attributes. This means we are more likely to end up with breaking changes, possibly without knowing it. Callers may also be unclear about which functions and classes they should be using. | ||
|
||
Decision | ||
******** | ||
|
||
Put most of the code into packages with ``internal`` in their name, and import the public bits into modules that are not marked that way. | ||
|
||
- ``edx_event_bus_kafka/__init__.py`` imports various producer and consumer module attributes | ||
- ``edx_event_bus_kafka/management/commands/*.py`` expose ``Command`` classes | ||
|
||
These will also be documented in the main README. | ||
|
||
The benefits of this setup include: | ||
|
||
* A clear designation of what is part of the public API. | ||
* The ability to refactor the implementation without changing the API. | ||
* A clear reminder to developers adding new code that it needs to be exposed if it is public. | ||
* A clear reminder to developers using the library not to use code from the internal implementation. | ||
|
||
Consequences | ||
************ | ||
|
||
Whenever a new class or function is added to the edx_django_utils public API, it should be implemented in the Django app's ``internal`` module and explicitly imported in its ``__init__.py`` module. | ||
|
||
There will be some additional friction when a developer looks up the docstrings of a public API element, since they'll first have to open the public module and then find the internal module. Having the public docstrings in a module marked "internal" also creates some dissonance. Our prediction is that this dissonance will be outweighed by the benefits of API stability. | ||
|
||
Rejected Alternatives | ||
********************* | ||
|
||
None. | ||
|
||
References | ||
********** | ||
|
||
This draws heavily on an ADR in ``edx-django-utils``: `<https://github.com/openedx/edx-django-utils/blob/master/docs/decisions/0004-public-api-and-app-organization.rst>`_ |
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 |
---|---|---|
@@ -1,5 +1,11 @@ | ||
""" | ||
Kafka implementation for Open edX event bus. | ||
Public API will be in this module for the most part. | ||
See ADR ``docs/decisions/0006-public-api-and-app-organization.rst`` for the reasoning. | ||
""" | ||
|
||
__version__ = '0.5.1' | ||
from edx_event_bus_kafka.internal.producer import EventProducerKafka, get_producer | ||
|
||
__version__ = '0.6.0' |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
""" | ||
Most of the implementation of the package is here and is internal-only. | ||
Public API will be in the ``edx_event_bus_kafka`` module for the most part. | ||
See ADR ``docs/decisions/0006-public-api-and-app-organization.rst`` for the reasoning. | ||
""" |
File renamed without changes.
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
File renamed without changes.
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
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
""" | ||
Management commands for the Kafka implementation. | ||
(Django requires this package structure.) | ||
""" |
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 |
---|---|---|
@@ -1,7 +1,5 @@ | ||
""" | ||
Makes ``consume_events`` management command available. | ||
Implements required ``APP.management.commands.*.Command`` structure. | ||
""" | ||
|
||
from edx_event_bus_kafka.consumer.event_consumer import ConsumeEventsCommand as Command # pylint: disable=unused-import | ||
from edx_event_bus_kafka.internal.consumer import ConsumeEventsCommand as Command # pylint: disable=unused-import |
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
Empty file.