Skip to content

Commit

Permalink
Moved examples pacakge out from eventsourcing package into repo root …
Browse files Browse the repository at this point in the history
…folder.
  • Loading branch information
johnbywater committed Nov 7, 2024
1 parent 473c6cc commit df56dc5
Show file tree
Hide file tree
Showing 98 changed files with 143 additions and 142 deletions.
3 changes: 2 additions & 1 deletion docs/topics/domain.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1331,7 +1331,8 @@ for an example of this style of implementing aggregate projector functions.
..
#include-when-testing
..
from eventsourcing.examples.cargoshipping.domainmodel import Location, singledispatchmethod
from eventsourcing.dispatch import singledispatchmethod
from examples.cargoshipping.domainmodel import Location
.. code-block:: python
Expand Down
6 changes: 3 additions & 3 deletions docs/topics/examples/aggregate1.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,18 @@ Python object class.
Domain model
------------

.. literalinclude:: ../../../eventsourcing/examples/aggregate1/domainmodel.py
.. literalinclude:: ../../../examples/aggregate1/domainmodel.py


Application
-----------


.. literalinclude:: ../../../eventsourcing/examples/aggregate1/application.py
.. literalinclude:: ../../../examples/aggregate1/application.py


Test case
---------


.. literalinclude:: ../../../eventsourcing/examples/aggregate1/test_application.py
.. literalinclude:: ../../../examples/aggregate1/test_application.py
6 changes: 3 additions & 3 deletions docs/topics/examples/aggregate2.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,18 @@ class as if it were a normal Python object class.
Domain model
------------

.. literalinclude:: ../../../eventsourcing/examples/aggregate2/domainmodel.py
.. literalinclude:: ../../../examples/aggregate2/domainmodel.py


Application
-----------


.. literalinclude:: ../../../eventsourcing/examples/aggregate2/application.py
.. literalinclude:: ../../../examples/aggregate2/application.py


Test case
---------


.. literalinclude:: ../../../eventsourcing/examples/aggregate2/test_application.py
.. literalinclude:: ../../../examples/aggregate2/test_application.py
6 changes: 3 additions & 3 deletions docs/topics/examples/aggregate3.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,18 @@ class as if it were a normal Python object class, albeit the aggregate class met
Domain model
------------

.. literalinclude:: ../../../eventsourcing/examples/aggregate3/domainmodel.py
.. literalinclude:: ../../../examples/aggregate3/domainmodel.py


Application
-----------


.. literalinclude:: ../../../eventsourcing/examples/aggregate3/application.py
.. literalinclude:: ../../../examples/aggregate3/application.py


Test case
---------


.. literalinclude:: ../../../eventsourcing/examples/aggregate3/test_application.py
.. literalinclude:: ../../../examples/aggregate3/test_application.py
6 changes: 3 additions & 3 deletions docs/topics/examples/aggregate4.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,18 @@ repository and when taking snapshots.
Domain model
------------

.. literalinclude:: ../../../eventsourcing/examples/aggregate4/domainmodel.py
.. literalinclude:: ../../../examples/aggregate4/domainmodel.py


Application
-----------


.. literalinclude:: ../../../eventsourcing/examples/aggregate4/application.py
.. literalinclude:: ../../../examples/aggregate4/application.py


Test case
---------


.. literalinclude:: ../../../eventsourcing/examples/aggregate4/test_application.py
.. literalinclude:: ../../../examples/aggregate4/test_application.py
6 changes: 3 additions & 3 deletions docs/topics/examples/aggregate5.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,18 @@ supplied when getting an aggregate from the repository and when taking snapshots
Domain model
------------

.. literalinclude:: ../../../eventsourcing/examples/aggregate5/domainmodel.py
.. literalinclude:: ../../../examples/aggregate5/domainmodel.py


Application
-----------


.. literalinclude:: ../../../eventsourcing/examples/aggregate5/application.py
.. literalinclude:: ../../../examples/aggregate5/application.py


Test case
---------


.. literalinclude:: ../../../eventsourcing/examples/aggregate5/test_application.py
.. literalinclude:: ../../../examples/aggregate5/test_application.py
6 changes: 3 additions & 3 deletions docs/topics/examples/aggregate6.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,18 @@ repository and when taking snapshots.
Domain model
------------

.. literalinclude:: ../../../eventsourcing/examples/aggregate6/domainmodel.py
.. literalinclude:: ../../../examples/aggregate6/domainmodel.py


Application
-----------


.. literalinclude:: ../../../eventsourcing/examples/aggregate6/application.py
.. literalinclude:: ../../../examples/aggregate6/application.py


Test case
---------


.. literalinclude:: ../../../eventsourcing/examples/aggregate6/test_application.py
.. literalinclude:: ../../../examples/aggregate6/test_application.py
8 changes: 4 additions & 4 deletions docs/topics/examples/aggregate7.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,25 +31,25 @@ aggregate events and from recorded snapshots.
Domain model
------------

.. literalinclude:: ../../../eventsourcing/examples/aggregate7/domainmodel.py
.. literalinclude:: ../../../examples/aggregate7/domainmodel.py


Application
-----------


.. literalinclude:: ../../../eventsourcing/examples/aggregate7/application.py
.. literalinclude:: ../../../examples/aggregate7/application.py


Persistence
-----------


.. literalinclude:: ../../../eventsourcing/examples/aggregate7/persistence.py
.. literalinclude:: ../../../examples/aggregate7/persistence.py


Test case
---------


.. literalinclude:: ../../../eventsourcing/examples/aggregate7/test_application.py
.. literalinclude:: ../../../examples/aggregate7/test_application.py
8 changes: 4 additions & 4 deletions docs/topics/examples/aggregate8.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,25 +30,25 @@ aggregate events and from recorded snapshots.
Domain model
------------

.. literalinclude:: ../../../eventsourcing/examples/aggregate8/domainmodel.py
.. literalinclude:: ../../../examples/aggregate8/domainmodel.py


Application
-----------


.. literalinclude:: ../../../eventsourcing/examples/aggregate8/application.py
.. literalinclude:: ../../../examples/aggregate8/application.py


Persistence
-----------


.. literalinclude:: ../../../eventsourcing/examples/aggregate8/persistence.py
.. literalinclude:: ../../../examples/aggregate8/persistence.py


Test case
---------


.. literalinclude:: ../../../eventsourcing/examples/aggregate8/test_application.py
.. literalinclude:: ../../../examples/aggregate8/test_application.py
6 changes: 3 additions & 3 deletions docs/topics/examples/bank-accounts.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ closed. Deposits and withdraws can be made on open accounts. Transfers can be
made between open accounts, if there are sufficient funds on the debited account.
All actions are atomic, including transfers between accounts.

.. literalinclude:: ../../../eventsourcing/examples/bankaccounts/application.py
.. literalinclude:: ../../../examples/bankaccounts/application.py


Domain model
Expand All @@ -29,7 +29,7 @@ the account has been closed. Debits are not allowed if the
balance would go below the overdraft limit. The overdraft
limit can be adjusted.

.. literalinclude:: ../../../eventsourcing/examples/bankaccounts/domainmodel.py
.. literalinclude:: ../../../examples/bankaccounts/domainmodel.py


Test case
Expand All @@ -40,4 +40,4 @@ might be used, the test runs through a scenario that
exercises all the methods of the application in one
test method.

.. literalinclude:: ../../../eventsourcing/examples/bankaccounts/test.py
.. literalinclude:: ../../../examples/bankaccounts/test.py
8 changes: 4 additions & 4 deletions docs/topics/examples/cargo-shipping.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ to be registered.
The ``Booking`` application defines and registers custom transcodings for the
custom value objects that are defined and used in the domain model.

.. literalinclude:: ../../../eventsourcing/examples/cargoshipping/application.py
.. literalinclude:: ../../../examples/cargoshipping/application.py

Domain model
------------
Expand All @@ -48,7 +48,7 @@ For the purpose of simplicity in this example, a fixed collection of routes betw
locations are also defined, but in practice these would be editable and could be
also modelled as event-sourced aggregates.

.. literalinclude:: ../../../eventsourcing/examples/cargoshipping/domainmodel.py
.. literalinclude:: ../../../examples/cargoshipping/domainmodel.py


Interface
Expand All @@ -66,7 +66,7 @@ the purposes of testing, we need to simulate the user selecting a preferred
itinerary from a list, which we do by picking the first in the list of presented
options using the ``select_preferred_itinerary()`` function.

.. literalinclude:: ../../../eventsourcing/examples/cargoshipping/interface.py
.. literalinclude:: ../../../examples/cargoshipping/interface.py


Test case
Expand All @@ -80,4 +80,4 @@ handling events as it is shipped around the world, recovering by
assigning a new route after the cargo was unloaded in the wrong place,
until finally the cargo is claimed at its correct destination.

.. literalinclude:: ../../../eventsourcing/examples/cargoshipping/test.py
.. literalinclude:: ../../../examples/cargoshipping/test.py
10 changes: 5 additions & 5 deletions docs/topics/examples/content-management-system.rst
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ system module guarantees that the diffs will always be applied in the correct or
this guarantee, the projection could become inconsistent, with the consequence that the diffs
will fail to be applied.

.. literalinclude:: ../../../eventsourcing/examples/contentmanagementsystem/application.py
.. literalinclude:: ../../../examples/contentmanagementsystem/application.py

System
------
Expand All @@ -54,7 +54,7 @@ A :class:`~eventsourcing.system.System` of applications is defined, in which the
``SearchIndexApplication`` follows the ``ContentManagementApplication``. This system
can then be used in any :class:`~eventsourcing.system.Runner`.

.. literalinclude:: ../../../eventsourcing/examples/contentmanagementsystem/system.py
.. literalinclude:: ../../../examples/contentmanagementsystem/system.py

PostgreSQL
----------
Expand All @@ -65,7 +65,7 @@ The PostgreSQL :class:`~eventsourcing.postgres.Factory` class is extended to inv
in a custom persistence module so that it can be used by the ``SearchIndexApplication``.


.. literalinclude:: ../../../eventsourcing/examples/contentmanagementsystem/postgres.py
.. literalinclude:: ../../../examples/contentmanagementsystem/postgres.py

SQLite
------
Expand All @@ -75,7 +75,7 @@ is used to define a custom :class:`~eventsourcing.persistence.ProcessRecorder` f
The SQLite :class:`~eventsourcing.sqlite.Factory` class is extended to involve this custom recorder
in a custom persistence module so that it can be used by the ``SearchIndexApplication``.

.. literalinclude:: ../../../eventsourcing/examples/contentmanagementsystem/sqlite.py
.. literalinclude:: ../../../examples/contentmanagementsystem/sqlite.py


Test case
Expand All @@ -86,4 +86,4 @@ and 'minerals'. Content is added to the pages. The content is searched with vari
the search results are checked. The test is executed twice, once with the application configured
for both PostgreSQL, and once for SQLite.

.. literalinclude:: ../../../eventsourcing/examples/contentmanagementsystem/test_system.py
.. literalinclude:: ../../../examples/contentmanagementsystem/test_system.py
8 changes: 4 additions & 4 deletions docs/topics/examples/content-management.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Please note, although the domain model (see below) involves a ``user_id`` event
none of the application command methods mention a ``user_id`` argument. Instead the value
is set in a context variable by callers of the application command methods (see the test below).

.. literalinclude:: ../../../eventsourcing/examples/contentmanagement/application.py
.. literalinclude:: ../../../examples/contentmanagement/application.py


Domain model
Expand Down Expand Up @@ -67,13 +67,13 @@ pages of text, with editable titles, and with editable "slugs" that can be used

A ``PageLogged`` event is also defined, and used to define a "page log" in the application.

.. literalinclude:: ../../../eventsourcing/examples/contentmanagement/domainmodel.py
.. literalinclude:: ../../../examples/contentmanagement/domainmodel.py


The ``create_diff()`` and ``apply_patch()`` functions use the Unix command line
tools ``patch`` and ``diff``.

.. literalinclude:: ../../../eventsourcing/examples/contentmanagement/utils.py
.. literalinclude:: ../../../examples/contentmanagement/utils.py


Test case
Expand All @@ -83,4 +83,4 @@ The test case below sets a user ID in the context variable. A page is created
and updated in various ways. At the end, all the page events are checked to
make sure they all have the user ID that was set in the context variable.

.. literalinclude:: ../../../eventsourcing/examples/contentmanagement/test.py
.. literalinclude:: ../../../examples/contentmanagement/test.py
10 changes: 5 additions & 5 deletions docs/topics/examples/searchable-content.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ parameters ``insert_pages`` and ``update_pages``. It also introduces a ``search(
expects a ``query`` argument and returns a list of pages. The application's recorders are expected
to be receptive to these variable keyword parameters and to support the ``search_pages()`` function.

.. literalinclude:: ../../../eventsourcing/examples/searchablecontent/application.py
.. literalinclude:: ../../../examples/searchablecontent/application.py


Persistence
Expand All @@ -29,7 +29,7 @@ defining abstract methods to search and select pages. These methods will be impl
for both PostgreSQL and SQLite, which will also create custom tables for page content with
a full text search indexes.

.. literalinclude:: ../../../eventsourcing/examples/searchablecontent/persistence.py
.. literalinclude:: ../../../examples/searchablecontent/persistence.py

The ``_insert_events()`` methods of the PostgreSQL and SQLite recorders are extended, so that
rows are inserted and updated, according to the information passed down from the application
Expand All @@ -43,7 +43,7 @@ The PostgreSQL recorder uses a GIN index and the ``websearch_to_tsquery()`` func
The PostgreSQL :class:`~eventsourcing.postgres.Factory` class is extended to involve this custom recorder
in a custom PostgreSQL persistence module so that it can be used by the ``ContentManagementApplication``.

.. literalinclude:: ../../../eventsourcing/examples/searchablecontent/postgres.py
.. literalinclude:: ../../../examples/searchablecontent/postgres.py

SQLite
------
Expand All @@ -52,7 +52,7 @@ The SQLite recorder uses a virtual table and the ``MATCH`` operator.
The SQLite :class:`~eventsourcing.sqlite.Factory` class is extended to involve this custom recorder
in a custom SQLite persistence module so that it can be used by the ``ContentManagementApplication``.

.. literalinclude:: ../../../eventsourcing/examples/searchablecontent/sqlite.py
.. literalinclude:: ../../../examples/searchablecontent/sqlite.py


Test case
Expand All @@ -64,4 +64,4 @@ content is searched with various queries and the search results are checked. The
test case is executed twice, once with the PostgreSQL persistence module, and once with the
SQLite persistence module.

.. literalinclude:: ../../../eventsourcing/examples/searchablecontent/test_application.py
.. literalinclude:: ../../../examples/searchablecontent/test_application.py
Loading

0 comments on commit df56dc5

Please sign in to comment.