-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Store event and command types in domain for easy retrieval
Use the `__type__` value present in events and commands to retrieve event and command classes from domain, instead of fetching by fully qualified name. This change is required to support cross-domain event processing. Also: - Fix bug with collecting identity value in associations - Remove unused delist functionality in registry
- Loading branch information
Showing
11 changed files
with
106 additions
and
87 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
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,21 @@ | ||
from protean import BaseCommand, BaseEventSourcedAggregate | ||
from protean.fields import Identifier, String | ||
|
||
|
||
class User(BaseEventSourcedAggregate): | ||
id = Identifier(identifier=True) | ||
email = String() | ||
name = String() | ||
|
||
|
||
class Register(BaseCommand): | ||
user_id = Identifier(identifier=True) | ||
email = String() | ||
name = String() | ||
|
||
|
||
def test_domain_stores_command_type_for_easy_retrieval(test_domain): | ||
test_domain.register(Register, part_of=User) | ||
test_domain.init(traverse=False) | ||
|
||
assert Register.__type__ in test_domain._events_and_commands |
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 |
---|---|---|
|
@@ -63,9 +63,11 @@ def test_construct_event_from_message(): | |
assert reconstructed_event.id == identifier | ||
|
||
|
||
def test_construct_command_from_message(): | ||
def test_construct_command_from_message(test_domain): | ||
identifier = str(uuid4()) | ||
command = Register(id=identifier, email="[email protected]", name="John Doe") | ||
command = test_domain._enrich_command( | ||
Register(id=identifier, email="[email protected]", name="John Doe") | ||
) | ||
message = Message.to_message(command) | ||
|
||
reconstructed_command = message.to_object() | ||
|
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