You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+28-60
Original file line number
Diff line number
Diff line change
@@ -225,13 +225,13 @@ Create a `foo/main.py` file and add the following content:
225
225
# foo/main.py
226
226
227
227
from pathlib import Path
228
-
from minos.aggregate import Aggregate, RootEntity
228
+
from minos.aggregate import Aggregate, Entity
229
229
from minos.common import EntrypointLauncher
230
230
from minos.cqrs import CommandService, QueryService
231
231
232
232
233
-
class Foo(RootEntity):
234
-
"""Foo RootEntity class."""
233
+
class Foo(Entity):
234
+
"""Foo Entity class."""
235
235
236
236
237
237
class FooAggregate(Aggregate[Foo]):
@@ -262,14 +262,12 @@ python foo/main.py
262
262
The way to model data in `minos` is highly inspired by the [Event Sourcing](https://microservices.io/patterns/data/event-sourcing.html) ideas. For this reason, the classes to be used to model data are:
263
263
264
264
* `minos.aggregate.Entity`: A model that has an identifier that gives it a unique identity, in the sense that some values from which it is composed could change, but its identity will continue being the same.
265
-
* `minos.aggregate.ExternalEntity`: A model that belongs to another microservice (or aggregate boundary) but needs to be used for some reason inside this microservice (or aggregate boundary).
266
-
* `minos.aggregate.RootEntity`: Is an `Entity` superset that provides global identity across the project compared to standard `Entity` models, that has only local identity (the `RootEntity` can be accessed from another microservices as `ExternalEntity` models, but standard `Entity` models can only be accessed within the microservice that define them). The `RootEntity` is also the one that interacts with the persistence layer (the `EventRepository` and `SnapshotRepository` instances).
267
-
* `minos.aggregate.Ref`: A wrapper class that provides the functionality to store a reference of other `RootEntity` or `ExternalEntity` instances.
265
+
* `minos.aggregate.Ref`: A wrapper class that provides the functionality to store a reference of other `Entity` instances.
268
266
* `minos.aggregate.EntitySet`: A container of `Entity` instances that takes advantage of the incremental behaviour of the `EventRepository`.
269
267
* `minos.aggregate.ValueObject`: A model that is only identified by the values that compose it, so that if some of them changes, then the model becomes completely different (for that reason, these models are immutable).
270
268
* `minos.aggregate.ValueObjectSet`: A container of `ValueObject` instances that takes advantage of the incremental behaviour of the `EventRepository.
271
-
* `minos.aggregate.Aggregate`: A collection of `Entity` and/or `ValueObject` models that are related to each other through a `RootEntity`.
272
-
* `minos.aggregate.Event`: A model that contains the difference between the a `RootEntity` instance and its previous version (if any).
269
+
* `minos.aggregate.Aggregate`: A collection of `Entity` and/or `ValueObject` models that are related to each other through a special `Entity` known as the Root Entity of the Aggregate.
270
+
* `minos.aggregate.Event`: A model that contains the difference between the a `Entity` instance and its previous version (if any).
273
271
274
272
Here is an example of the creation the `Foo` aggregate. In this case, it has two attributes, a `bar` being a `str`, and a `foobar` being an optional reference to the external `FooBar` aggregate, which it is assumed that it has a `something` attribute.
275
273
@@ -279,20 +277,14 @@ Here is an example of the creation the `Foo` aggregate. In this case, it has two
279
277
from __future__ import annotations
280
278
from typing import Optional
281
279
from uuid import UUID
282
-
from minos.aggregate import Aggregate, RootEntity, ExternalEntity, Ref
280
+
from minos.aggregate import Aggregate, Entity, Ref
283
281
284
282
285
-
class Foo(RootEntity):
286
-
"""Foo RootEntity class."""
283
+
class Foo(Entity):
284
+
"""Foo Entity class."""
287
285
288
286
bar: str
289
-
foobar: Optional[Ref[FooBar]]
290
-
291
-
292
-
class FooBar(ExternalEntity):
293
-
"""FooBar ExternalEntity clas."""
294
-
295
-
something: str
287
+
foobar: Optional[Ref["FooBar"]]
296
288
297
289
298
290
class FooAggregate(Aggregate[Foo]):
@@ -334,22 +326,16 @@ from pathlib import Path
334
326
from typing import Optional
335
327
from uuid import UUID
336
328
337
-
from minos.aggregate import Aggregate, RootEntity, ExternalEntity, Ref
329
+
from minos.aggregate import Aggregate, Entity, Ref
338
330
from minos.common import EntrypointLauncher
339
331
from minos.cqrs import CommandService, QueryService
340
332
341
333
342
-
class Foo(RootEntity):
343
-
"""Foo RootEntity class."""
334
+
class Foo(Entity):
335
+
"""Foo Entity class."""
344
336
345
337
bar: str
346
-
foobar: Optional[Ref[FooBar]]
347
-
348
-
349
-
class FooBar(ExternalEntity):
350
-
"""FooBar ExternalEntity clas."""
351
-
352
-
something: str
338
+
foobar: Optional[Ref["FooBar"]]
353
339
354
340
355
341
class FooAggregate(Aggregate[Foo]):
@@ -436,23 +422,17 @@ from pathlib import Path
436
422
from typing import Optional
437
423
from uuid import UUID
438
424
439
-
from minos.aggregate import Aggregate, RootEntity, ExternalEntity, Ref
425
+
from minos.aggregate import Aggregate, Entity, Ref
440
426
from minos.common import EntrypointLauncher
441
427
from minos.cqrs import CommandService, QueryService
442
428
from minos.networks import Request, Response, enroute
443
429
444
430
445
-
class Foo(RootEntity):
446
-
"""Foo RootEntity class."""
431
+
class Foo(Entity):
432
+
"""Foo Entity class."""
447
433
448
434
bar: str
449
-
foobar: Optional[Ref[FooBar]]
450
-
451
-
452
-
class FooBar(ExternalEntity):
453
-
"""FooBar ExternalEntity clas."""
454
-
455
-
something: str
435
+
foobar: Optional[Ref["FooBar"]]
456
436
457
437
458
438
class FooAggregate(Aggregate[Foo]):
@@ -594,23 +574,17 @@ from pathlib import Path
594
574
from typing import Optional
595
575
from uuid import UUID
596
576
597
-
from minos.aggregate import Aggregate, RootEntity, ExternalEntity, Ref
577
+
from minos.aggregate import Aggregate, Entity, Ref
598
578
from minos.common import EntrypointLauncher
599
579
from minos.cqrs import CommandService, QueryService
600
580
from minos.networks import Request, Response, enroute
601
581
602
582
603
-
class Foo(RootEntity):
604
-
"""Foo RootEntity class."""
583
+
class Foo(Entity):
584
+
"""Foo Entity class."""
605
585
606
586
bar: str
607
-
foobar: Optional[Ref[FooBar]]
608
-
609
-
610
-
class FooBar(ExternalEntity):
611
-
"""FooBar ExternalEntity clas."""
612
-
613
-
something: str
587
+
foobar: Optional[Ref["FooBar"]]
614
588
615
589
616
590
class FooAggregate(Aggregate[Foo]):
@@ -797,24 +771,18 @@ from pathlib import Path
797
771
from typing import Optional
798
772
from uuid importUUID
799
773
800
-
from minos.aggregate import Aggregate, RootEntity, ExternalEntity, Ref
774
+
from minos.aggregate import Aggregate, Entity, Ref
801
775
from minos.common import ModelType, EntrypointLauncher
802
776
from minos.cqrs import CommandService, QueryService
803
777
from minos.networks import Request, Response, enroute
804
778
from minos.saga import Saga, SagaContext, SagaRequest, SagaResponse
805
779
806
780
807
-
classFoo(RootEntity):
808
-
"""Foo RootEntity class."""
781
+
classFoo(Entity):
782
+
"""Foo Entity class."""
809
783
810
784
bar: str
811
-
foobar: Optional[Ref[FooBar]]
812
-
813
-
814
-
classFooBar(ExternalEntity):
815
-
"""FooBar ExternalEntity clas."""
816
-
817
-
something: str
785
+
foobar: Optional[Ref["FooBar"]]
818
786
819
787
820
788
classFooAggregate(Aggregate[Foo]):
@@ -1046,13 +1014,13 @@ from __future__ import annotations
1046
1014
from pathlib import Path
1047
1015
from uuid import UUID
1048
1016
1049
-
from minos.aggregate import Aggregate, RootEntity
1017
+
from minos.aggregate import Aggregate, Entity
1050
1018
from minos.common import EntrypointLauncher
1051
1019
from minos.cqrs import CommandService
1052
1020
from minos.networks import Request, Response, enroute
0 commit comments