diff --git a/microservices/authentication/config.yml b/microservices/authentication/config.yml index bc1f88ab..f7d194f1 100644 --- a/microservices/authentication/config.yml +++ b/microservices/authentication/config.yml @@ -4,8 +4,8 @@ service: injections: lock_pool: minos.common.PostgreSqlLockPool postgresql_pool: minos.common.PostgreSqlPool - broker_publisher: minos.networks.PostgreSqlQueuedKafkaBrokerPublisher - broker_subscriber_builder: minos.networks.PostgreSqlQueuedKafkaBrokerSubscriberBuilder + broker_publisher: minos.plugins.kafka.InMemoryQueuedKafkaBrokerPublisher + broker_subscriber_builder: minos.plugins.kafka.InMemoryQueuedKafkaBrokerSubscriberBuilder broker_pool: minos.networks.BrokerClientPool transaction_repository: minos.aggregate.PostgreSqlTransactionRepository event_repository: minos.aggregate.PostgreSqlEventRepository @@ -55,6 +55,6 @@ saga: storage: path: "./auth.lmdb" discovery: - client: minos.networks.MinosDiscoveryClient + client: minos.plugins.minos_discovery.MinosDiscoveryClient host: localhost port: 5567 diff --git a/microservices/authentication/poetry.lock b/microservices/authentication/poetry.lock index dfa11d5c..10d3cb6c 100644 --- a/microservices/authentication/poetry.lock +++ b/microservices/authentication/poetry.lock @@ -325,81 +325,140 @@ category = "dev" optional = false python-versions = "*" +[[package]] +name = "minos-broker-kafka" +version = "0.4.1" +description = "Minos Broker Kafka package" +category = "main" +optional = false +python-versions = "^3.9" +develop = true + +[package.dependencies] +aiokafka = "^0.7.0" +minos-microservice-common = "^0.4.0" +minos-microservice-networks = "^0.4.0" + +[package.source] +type = "directory" +url = "../../../minos-python/packages/plugins/minos-broker-kafka" + +[[package]] +name = "minos-discovery-minos" +version = "0.4.1" +description = "Minos Discovery Minos package" +category = "main" +optional = false +python-versions = "^3.9" +develop = true + +[package.dependencies] +minos-microservice-common = "^0.4.0" +minos-microservice-networks = "^0.4.0" + +[package.source] +type = "directory" +url = "../../../minos-python/packages/plugins/minos-discovery-minos" + [[package]] name = "minos-microservice-aggregate" -version = "0.4.0" -description = "Python Package for Minos Microservices containing all the Aggregate stuff" +version = "0.4.1" +description = "Python Package for Minos Microservices containing all the RootEntity stuff" category = "main" optional = false -python-versions = ">=3.9,<4.0" +python-versions = "^3.9" +develop = true [package.dependencies] -minos-microservice-common = ">=0.4.0,<0.5.0" -minos-microservice-networks = ">=0.4.0,<0.5.0" +minos-microservice-common = "^0.4.0" +minos-microservice-networks = "^0.4.0" + +[package.source] +type = "directory" +url = "../../../minos-python/packages/core/minos-microservice-aggregate" [[package]] name = "minos-microservice-common" -version = "0.4.0" +version = "0.4.1" description = "Python Package with common Classes and Utilities used in Minos Microservices." category = "main" optional = false -python-versions = ">=3.9,<4.0" +python-versions = "^3.9" +develop = true [package.dependencies] -aiomisc = ">=14.0.3,<15.0.0" -aiopg = ">=1.2.1,<2.0.0" -cached-property = ">=1.5.2,<2.0.0" -dependency-injector = ">=4.32.2,<5.0.0" -fastavro = ">=1.4.0,<2.0.0" -lmdb = ">=1.2.1,<2.0.0" -orjson = ">=3.5.2,<4.0.0" +aiomisc = "^14.0.3" +aiopg = "^1.2.1" +cached-property = "^1.5.2" +dependency-injector = "^4.32.2" +fastavro = "^1.4.0" +lmdb = "^1.2.1" +orjson = "^3.5.2" PyYAML = ">=5.4.1,<7.0.0" +[package.source] +type = "directory" +url = "../../../minos-python/packages/core/minos-microservice-common" + [[package]] name = "minos-microservice-cqrs" -version = "0.4.0" +version = "0.4.1" description = "Minos Microservice CQRS package" category = "main" optional = false -python-versions = ">=3.9,<4.0" +python-versions = "^3.9" +develop = true [package.dependencies] -dependency-injector = ">=4.34.0,<5.0.0" -minos-microservice-aggregate = ">=0.4.0,<0.5.0" -minos-microservice-common = ">=0.4.0,<0.5.0" -minos-microservice-networks = ">=0.4.0,<0.5.0" +dependency-injector = "^4.34.0" +minos-microservice-aggregate = "^0.4.0" +minos-microservice-common = "^0.4.0" +minos-microservice-networks = "^0.4.0" + +[package.source] +type = "directory" +url = "../../../minos-python/packages/core/minos-microservice-cqrs" [[package]] name = "minos-microservice-networks" -version = "0.4.0" +version = "0.4.1" description = "Python Package with the common network classes and utilities used in Minos Microservice." category = "main" optional = false -python-versions = ">=3.9,<4.0" +python-versions = "^3.9" +develop = true [package.dependencies] -aiohttp = ">=3.7.4,<4.0.0" -aiokafka = ">=0.7.0,<0.8.0" -aiomisc = ">=14.0.3,<15.0.0" -aiopg = ">=1.2.1,<2.0.0" -crontab = ">=0.23.0,<0.24.0" -dependency-injector = ">=4.32.2,<5.0.0" -minos-microservice-common = ">=0.4.0,<0.5.0" -orjson = ">=3.6.5,<4.0.0" +aiohttp = "^3.7.4" +aiomisc = "^14.0.3" +aiopg = "^1.2.1" +crontab = "^0.23.0" +dependency-injector = "^4.32.2" +minos-microservice-common = "^0.4.0" +orjson = "^3.6.5" + +[package.source] +type = "directory" +url = "../../../minos-python/packages/core/minos-microservice-networks" [[package]] name = "minos-microservice-saga" -version = "0.4.0" +version = "0.4.1" description = "Saga Library for MinOS project." category = "main" optional = false -python-versions = ">=3.9,<4.0" +python-versions = "^3.9" +develop = true [package.dependencies] -dependency-injector = ">=4.32.2,<5.0.0" -minos-microservice-aggregate = ">=0.4.0,<0.5.0" -minos-microservice-common = ">=0.4.0,<0.5.0" -minos-microservice-networks = ">=0.4.0,<0.5.0" +dependency-injector = "^4.32.2" +minos-microservice-aggregate = "^0.4.0" +minos-microservice-common = "^0.4.0" +minos-microservice-networks = "^0.4.0" + +[package.source] +type = "directory" +url = "../../../minos-python/packages/core/minos-microservice-saga" [[package]] name = "multidict" @@ -629,7 +688,7 @@ multidict = ">=4.0" [metadata] lock-version = "1.1" python-versions = "^3.9" -content-hash = "403ecde20bf233bde5b7c34999054453942c6d007fceaf06f9814bb9916796c1" +content-hash = "6be3f25508c6aa983167b59a6df639b85f71aea0d635d0d0b497950088a7d69e" [metadata.files] aiohttp = [ @@ -1065,26 +1124,13 @@ mccabe = [ {file = "mccabe-0.6.1-py2.py3-none-any.whl", hash = "sha256:ab8a6258860da4b6677da4bd2fe5dc2c659cff31b3ee4f7f5d64e79735b80d42"}, {file = "mccabe-0.6.1.tar.gz", hash = "sha256:dd8d182285a0fe56bace7f45b5e7d1a6ebcbf524e8f3bd87eb0f125271b8831f"}, ] -minos-microservice-aggregate = [ - {file = "minos-microservice-aggregate-0.4.0.tar.gz", hash = "sha256:2ada8638f7bfec2c120df452648f438710d7e5dd63612d09c1ba7f8cb41ba23d"}, - {file = "minos_microservice_aggregate-0.4.0-py3-none-any.whl", hash = "sha256:9edcb9931f7aeb9a472b64259fd7d0c1363d9ea5ee59fc5282642748a1c76ed3"}, -] -minos-microservice-common = [ - {file = "minos-microservice-common-0.4.0.tar.gz", hash = "sha256:b74995fba27ca383e52804e2c0013350d747dcc03c38098ad2026a9cceb04996"}, - {file = "minos_microservice_common-0.4.0-py3-none-any.whl", hash = "sha256:65cecd809b243007d57740b7d40349544d6e98a69ce84aac86ca06a2a4b97e29"}, -] -minos-microservice-cqrs = [ - {file = "minos-microservice-cqrs-0.4.0.tar.gz", hash = "sha256:f494a4916b0ec4ad14e813e617ac307f895fa97d777e5fd457b1c5c3c45db471"}, - {file = "minos_microservice_cqrs-0.4.0-py3-none-any.whl", hash = "sha256:f6998cfb9cb870139f851166f6b0e0975af1ce3aac0171fe862260b9178c7f76"}, -] -minos-microservice-networks = [ - {file = "minos-microservice-networks-0.4.0.tar.gz", hash = "sha256:4aa1791a723e148bc06fcb15e39ac9bd852d54a5101dcf4f5e1d6a7b472b9888"}, - {file = "minos_microservice_networks-0.4.0-py3-none-any.whl", hash = "sha256:94ef940aa7c5a3f00127bed312ebea1c635be569c6500c81ce7914cbb5c4c7e9"}, -] -minos-microservice-saga = [ - {file = "minos-microservice-saga-0.4.0.tar.gz", hash = "sha256:6c1d7ff41261253512d1f1bb00a9d0c54b4b9860df470c71a424547fbe01638c"}, - {file = "minos_microservice_saga-0.4.0-py3-none-any.whl", hash = "sha256:2cb332de5e405243b71f38ed7453c0f6d692e96827bb76811595425383fad18b"}, -] +minos-broker-kafka = [] +minos-discovery-minos = [] +minos-microservice-aggregate = [] +minos-microservice-common = [] +minos-microservice-cqrs = [] +minos-microservice-networks = [] +minos-microservice-saga = [] multidict = [ {file = "multidict-6.0.2-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:0b9e95a740109c6047602f4db4da9949e6c5945cefbad34a1299775ddc9a62e2"}, {file = "multidict-6.0.2-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:ac0e27844758d7177989ce406acc6a83c16ed4524ebc363c1f748cba184d89d3"}, diff --git a/microservices/authentication/pyproject.toml b/microservices/authentication/pyproject.toml index 7ebec317..26b704de 100644 --- a/microservices/authentication/pyproject.toml +++ b/microservices/authentication/pyproject.toml @@ -7,11 +7,13 @@ packages = [{ include = "src" }] [tool.poetry.dependencies] python = "^3.9" -minos-microservice-common = "^0.4.0" -minos-microservice-networks = "^0.4.0" -minos-microservice-aggregate = "^0.4.0" -minos-microservice-saga = "^0.4.0" -minos-microservice-cqrs = "^0.4.0" +minos-microservice-common = { path = "../../../minos-python/packages/core/minos-microservice-common", develop = true } +minos-microservice-networks = { path = "../../../minos-python/packages/core/minos-microservice-networks", develop = true } +minos-microservice-aggregate = { path = "../../../minos-python/packages/core/minos-microservice-aggregate", develop = true } +minos-microservice-saga = { path = "../../../minos-python/packages/core/minos-microservice-saga", develop = true } +minos-microservice-cqrs = { path = "../../../minos-python/packages/core/minos-microservice-cqrs", develop = true } +minos-broker-kafka = { path = "../../../minos-python/packages/plugins/minos-broker-kafka", develop = true } +minos-discovery-minos = { path = "../../../minos-python/packages/plugins/minos-discovery-minos", develop = true } typer = "^0.3.2" PyJWT = "^2.1.0" SQLAlchemy = "1.4.22" diff --git a/microservices/authentication/src/aggregates.py b/microservices/authentication/src/aggregates.py index d140b488..74cd72be 100644 --- a/microservices/authentication/src/aggregates.py +++ b/microservices/authentication/src/aggregates.py @@ -3,15 +3,15 @@ ) from minos.aggregate import ( - Aggregate, - AggregateRef, + RootEntity, + ExternalEntity, Condition, - ModelRef, + Ref, ) -class Credentials(Aggregate): - """Credentials Aggregate class. +class Credentials(RootEntity): + """Credentials RootEntity class. The purpose of this aggregate is to store the needed information to be authenticated. """ @@ -19,7 +19,7 @@ class Credentials(Aggregate): username: str password: str active: bool - user: ModelRef[Customer] + user: Ref[Customer] @classmethod async def exists_username(cls, username: str) -> bool: @@ -35,5 +35,5 @@ async def exists_username(cls, username: str) -> bool: return False -class Customer(AggregateRef): - """Customer Aggregate-Reference class.""" +class Customer(ExternalEntity): + """Customer ExternalEntity class.""" diff --git a/microservices/authentication/src/commands/services.py b/microservices/authentication/src/commands/services.py index 720e01cc..5bb637be 100644 --- a/microservices/authentication/src/commands/services.py +++ b/microservices/authentication/src/commands/services.py @@ -75,7 +75,7 @@ async def delete_credentials(self, request: Request) -> None: async def user_deleted(self, request: Request) -> None: """Delete the associated credentials to the already deleted user. - :param request: A ``Request`` containing a ``AggregateDiff`` instance. + :param request: A ``Request`` containing a ``Event`` instance. :return: This method does not return anything. """ diff --git a/microservices/authentication/src/queries/services.py b/microservices/authentication/src/queries/services.py index 4c266d08..09adc272 100644 --- a/microservices/authentication/src/queries/services.py +++ b/microservices/authentication/src/queries/services.py @@ -10,7 +10,7 @@ InvalidTokenError, ) from minos.aggregate import ( - AggregateDiff, + Event, ) from minos.cqrs import ( QueryService, @@ -124,8 +124,8 @@ async def unique_username(self, request: Request) -> Response: async def credentials_created(self, request: Request) -> None: """Handle the ``CredentialsCreated`` domain event. - :param request: A ``Request`` instance containing the ``AggregateDiff``. + :param request: A ``Request`` instance containing the ``Event``. :return: This method does not return anything. """ - diff: AggregateDiff = await request.content() + diff: Event = await request.content() await self.repository.create_credentials(diff.uuid, diff.username, diff.password, diff.active, diff.user) diff --git a/microservices/cart/config.yml b/microservices/cart/config.yml index baf18e68..294cb234 100644 --- a/microservices/cart/config.yml +++ b/microservices/cart/config.yml @@ -4,8 +4,8 @@ service: injections: lock_pool: minos.common.PostgreSqlLockPool postgresql_pool: minos.common.PostgreSqlPool - broker_publisher: minos.networks.PostgreSqlQueuedKafkaBrokerPublisher - broker_subscriber_builder: minos.networks.PostgreSqlQueuedKafkaBrokerSubscriberBuilder + broker_publisher: minos.plugins.kafka.InMemoryQueuedKafkaBrokerPublisher + broker_subscriber_builder: minos.plugins.kafka.InMemoryQueuedKafkaBrokerSubscriberBuilder broker_pool: minos.networks.BrokerClientPool transaction_repository: minos.aggregate.PostgreSqlTransactionRepository event_repository: minos.aggregate.PostgreSqlEventRepository @@ -55,6 +55,6 @@ saga: storage: path: "./cart.lmdb" discovery: - client: minos.networks.MinosDiscoveryClient + client: minos.plugins.minos_discovery.MinosDiscoveryClient host: localhost port: 5567 \ No newline at end of file diff --git a/microservices/cart/poetry.lock b/microservices/cart/poetry.lock index b935da03..609e3767 100644 --- a/microservices/cart/poetry.lock +++ b/microservices/cart/poetry.lock @@ -317,81 +317,140 @@ category = "dev" optional = false python-versions = "*" +[[package]] +name = "minos-broker-kafka" +version = "0.4.1" +description = "Minos Broker Kafka package" +category = "main" +optional = false +python-versions = "^3.9" +develop = true + +[package.dependencies] +aiokafka = "^0.7.0" +minos-microservice-common = "^0.4.0" +minos-microservice-networks = "^0.4.0" + +[package.source] +type = "directory" +url = "../../../minos-python/packages/plugins/minos-broker-kafka" + +[[package]] +name = "minos-discovery-minos" +version = "0.4.1" +description = "Minos Discovery Minos package" +category = "main" +optional = false +python-versions = "^3.9" +develop = true + +[package.dependencies] +minos-microservice-common = "^0.4.0" +minos-microservice-networks = "^0.4.0" + +[package.source] +type = "directory" +url = "../../../minos-python/packages/plugins/minos-discovery-minos" + [[package]] name = "minos-microservice-aggregate" -version = "0.4.0" -description = "Python Package for Minos Microservices containing all the Aggregate stuff" +version = "0.4.1" +description = "Python Package for Minos Microservices containing all the RootEntity stuff" category = "main" optional = false -python-versions = ">=3.9,<4.0" +python-versions = "^3.9" +develop = true [package.dependencies] -minos-microservice-common = ">=0.4.0,<0.5.0" -minos-microservice-networks = ">=0.4.0,<0.5.0" +minos-microservice-common = "^0.4.0" +minos-microservice-networks = "^0.4.0" + +[package.source] +type = "directory" +url = "../../../minos-python/packages/core/minos-microservice-aggregate" [[package]] name = "minos-microservice-common" -version = "0.4.0" +version = "0.4.1" description = "Python Package with common Classes and Utilities used in Minos Microservices." category = "main" optional = false -python-versions = ">=3.9,<4.0" +python-versions = "^3.9" +develop = true [package.dependencies] -aiomisc = ">=14.0.3,<15.0.0" -aiopg = ">=1.2.1,<2.0.0" -cached-property = ">=1.5.2,<2.0.0" -dependency-injector = ">=4.32.2,<5.0.0" -fastavro = ">=1.4.0,<2.0.0" -lmdb = ">=1.2.1,<2.0.0" -orjson = ">=3.5.2,<4.0.0" +aiomisc = "^14.0.3" +aiopg = "^1.2.1" +cached-property = "^1.5.2" +dependency-injector = "^4.32.2" +fastavro = "^1.4.0" +lmdb = "^1.2.1" +orjson = "^3.5.2" PyYAML = ">=5.4.1,<7.0.0" +[package.source] +type = "directory" +url = "../../../minos-python/packages/core/minos-microservice-common" + [[package]] name = "minos-microservice-cqrs" -version = "0.4.0" +version = "0.4.1" description = "Minos Microservice CQRS package" category = "main" optional = false -python-versions = ">=3.9,<4.0" +python-versions = "^3.9" +develop = true [package.dependencies] -dependency-injector = ">=4.34.0,<5.0.0" -minos-microservice-aggregate = ">=0.4.0,<0.5.0" -minos-microservice-common = ">=0.4.0,<0.5.0" -minos-microservice-networks = ">=0.4.0,<0.5.0" +dependency-injector = "^4.34.0" +minos-microservice-aggregate = "^0.4.0" +minos-microservice-common = "^0.4.0" +minos-microservice-networks = "^0.4.0" + +[package.source] +type = "directory" +url = "../../../minos-python/packages/core/minos-microservice-cqrs" [[package]] name = "minos-microservice-networks" -version = "0.4.0" +version = "0.4.1" description = "Python Package with the common network classes and utilities used in Minos Microservice." category = "main" optional = false -python-versions = ">=3.9,<4.0" +python-versions = "^3.9" +develop = true [package.dependencies] -aiohttp = ">=3.7.4,<4.0.0" -aiokafka = ">=0.7.0,<0.8.0" -aiomisc = ">=14.0.3,<15.0.0" -aiopg = ">=1.2.1,<2.0.0" -crontab = ">=0.23.0,<0.24.0" -dependency-injector = ">=4.32.2,<5.0.0" -minos-microservice-common = ">=0.4.0,<0.5.0" -orjson = ">=3.6.5,<4.0.0" +aiohttp = "^3.7.4" +aiomisc = "^14.0.3" +aiopg = "^1.2.1" +crontab = "^0.23.0" +dependency-injector = "^4.32.2" +minos-microservice-common = "^0.4.0" +orjson = "^3.6.5" + +[package.source] +type = "directory" +url = "../../../minos-python/packages/core/minos-microservice-networks" [[package]] name = "minos-microservice-saga" -version = "0.4.0" +version = "0.4.1" description = "Saga Library for MinOS project." category = "main" optional = false -python-versions = ">=3.9,<4.0" +python-versions = "^3.9" +develop = true [package.dependencies] -dependency-injector = ">=4.32.2,<5.0.0" -minos-microservice-aggregate = ">=0.4.0,<0.5.0" -minos-microservice-common = ">=0.4.0,<0.5.0" -minos-microservice-networks = ">=0.4.0,<0.5.0" +dependency-injector = "^4.32.2" +minos-microservice-aggregate = "^0.4.0" +minos-microservice-common = "^0.4.0" +minos-microservice-networks = "^0.4.0" + +[package.source] +type = "directory" +url = "../../../minos-python/packages/core/minos-microservice-saga" [[package]] name = "more-itertools" @@ -623,7 +682,7 @@ multidict = ">=4.0" [metadata] lock-version = "1.1" python-versions = "^3.9" -content-hash = "51f97137bb2d470f472478558b670ad76f21bca07cca408cbf7c91a1206f4169" +content-hash = "48109052dd28bdaa5821d07aa0850af45a05b64472eb589cf7f50fbd96c92f2f" [metadata.files] aiohttp = [ @@ -1055,26 +1114,13 @@ mccabe = [ {file = "mccabe-0.6.1-py2.py3-none-any.whl", hash = "sha256:ab8a6258860da4b6677da4bd2fe5dc2c659cff31b3ee4f7f5d64e79735b80d42"}, {file = "mccabe-0.6.1.tar.gz", hash = "sha256:dd8d182285a0fe56bace7f45b5e7d1a6ebcbf524e8f3bd87eb0f125271b8831f"}, ] -minos-microservice-aggregate = [ - {file = "minos-microservice-aggregate-0.4.0.tar.gz", hash = "sha256:2ada8638f7bfec2c120df452648f438710d7e5dd63612d09c1ba7f8cb41ba23d"}, - {file = "minos_microservice_aggregate-0.4.0-py3-none-any.whl", hash = "sha256:9edcb9931f7aeb9a472b64259fd7d0c1363d9ea5ee59fc5282642748a1c76ed3"}, -] -minos-microservice-common = [ - {file = "minos-microservice-common-0.4.0.tar.gz", hash = "sha256:b74995fba27ca383e52804e2c0013350d747dcc03c38098ad2026a9cceb04996"}, - {file = "minos_microservice_common-0.4.0-py3-none-any.whl", hash = "sha256:65cecd809b243007d57740b7d40349544d6e98a69ce84aac86ca06a2a4b97e29"}, -] -minos-microservice-cqrs = [ - {file = "minos-microservice-cqrs-0.4.0.tar.gz", hash = "sha256:f494a4916b0ec4ad14e813e617ac307f895fa97d777e5fd457b1c5c3c45db471"}, - {file = "minos_microservice_cqrs-0.4.0-py3-none-any.whl", hash = "sha256:f6998cfb9cb870139f851166f6b0e0975af1ce3aac0171fe862260b9178c7f76"}, -] -minos-microservice-networks = [ - {file = "minos-microservice-networks-0.4.0.tar.gz", hash = "sha256:4aa1791a723e148bc06fcb15e39ac9bd852d54a5101dcf4f5e1d6a7b472b9888"}, - {file = "minos_microservice_networks-0.4.0-py3-none-any.whl", hash = "sha256:94ef940aa7c5a3f00127bed312ebea1c635be569c6500c81ce7914cbb5c4c7e9"}, -] -minos-microservice-saga = [ - {file = "minos-microservice-saga-0.4.0.tar.gz", hash = "sha256:6c1d7ff41261253512d1f1bb00a9d0c54b4b9860df470c71a424547fbe01638c"}, - {file = "minos_microservice_saga-0.4.0-py3-none-any.whl", hash = "sha256:2cb332de5e405243b71f38ed7453c0f6d692e96827bb76811595425383fad18b"}, -] +minos-broker-kafka = [] +minos-discovery-minos = [] +minos-microservice-aggregate = [] +minos-microservice-common = [] +minos-microservice-cqrs = [] +minos-microservice-networks = [] +minos-microservice-saga = [] more-itertools = [ {file = "more-itertools-8.12.0.tar.gz", hash = "sha256:7dc6ad46f05f545f900dd59e8dfb4e84a4827b97b3cfecb175ea0c7d247f6064"}, {file = "more_itertools-8.12.0-py3-none-any.whl", hash = "sha256:43e6dd9942dffd72661a2c4ef383ad7da1e6a3e968a927ad7a6083ab410a688b"}, diff --git a/microservices/cart/pyproject.toml b/microservices/cart/pyproject.toml index f5398c35..0ecf325b 100644 --- a/microservices/cart/pyproject.toml +++ b/microservices/cart/pyproject.toml @@ -7,11 +7,13 @@ packages = [{ include = "src" }] [tool.poetry.dependencies] python = "^3.9" -minos-microservice-common = "^0.4.0" -minos-microservice-networks = "^0.4.0" -minos-microservice-aggregate = "^0.4.0" -minos-microservice-saga = "^0.4.0" -minos-microservice-cqrs = "^0.4.0" +minos-microservice-common = { path = "../../../minos-python/packages/core/minos-microservice-common", develop = true } +minos-microservice-networks = { path = "../../../minos-python/packages/core/minos-microservice-networks", develop = true } +minos-microservice-aggregate = { path = "../../../minos-python/packages/core/minos-microservice-aggregate", develop = true } +minos-microservice-saga = { path = "../../../minos-python/packages/core/minos-microservice-saga", develop = true } +minos-microservice-cqrs = { path = "../../../minos-python/packages/core/minos-microservice-cqrs", develop = true } +minos-broker-kafka = { path = "../../../minos-python/packages/plugins/minos-broker-kafka", develop = true } +minos-discovery-minos = { path = "../../../minos-python/packages/plugins/minos-discovery-minos", develop = true } typer = "^0.3.2" SQLAlchemy = "1.4.22" diff --git a/microservices/cart/src/aggregates.py b/microservices/cart/src/aggregates.py index 7d50d6ee..4d38338b 100644 --- a/microservices/cart/src/aggregates.py +++ b/microservices/cart/src/aggregates.py @@ -3,16 +3,16 @@ ) from minos.aggregate import ( - Aggregate, - AggregateRef, + RootEntity, + ExternalEntity, Entity, EntitySet, - ModelRef, + Ref, ) -class Cart(Aggregate): - """Cart Aggregate class.""" +class Cart(RootEntity): + """Cart RootEntity class.""" user: int entries: EntitySet[CartEntry] @@ -22,11 +22,11 @@ class CartEntry(Entity): """Cart Item DeclarativeModel class.""" quantity: int - product: ModelRef[Product] + product: Ref[Product] -class Product(AggregateRef): - """Product AggregateRef class.""" +class Product(ExternalEntity): + """Product ExternalEntity class.""" title: str description: str diff --git a/microservices/cart/src/queries/services.py b/microservices/cart/src/queries/services.py index efd3ed0b..74b7a02a 100644 --- a/microservices/cart/src/queries/services.py +++ b/microservices/cart/src/queries/services.py @@ -2,7 +2,7 @@ Provide, ) from minos.aggregate import ( - AggregateDiff, + Event, ) from minos.cqrs import ( QueryService, @@ -48,7 +48,7 @@ async def cart_created(self, request: Request) -> None: :param request: A request instance containing the aggregate difference. :return: This method does not return anything. """ - diff: AggregateDiff = await request.content() + diff: Event = await request.content() await self.repository.create_cart(diff.uuid, diff.version, diff.user) @@ -58,7 +58,7 @@ async def cart_updated(self, request: Request) -> None: :param request: A request instance containing the aggregate difference. :return: This method does not return anything. """ - diff: AggregateDiff = await request.content() + diff: Event = await request.content() print(diff) @enroute.broker.event("CartUpdated.entries.create") @@ -67,7 +67,7 @@ async def cart_item_created(self, request: Request) -> None: :param request: A request instance containing the aggregate difference. :return: This method does not return anything. """ - diff: AggregateDiff = await request.content() + diff: Event = await request.content() for entry in diff["entries"]: await self.repository.insert_cart_item( @@ -85,7 +85,7 @@ async def cart_item_deleted(self, request: Request) -> None: :param request: A request instance containing the aggregate difference. :return: This method does not return anything. """ - diff: AggregateDiff = await request.content() + diff: Event = await request.content() for entry in diff["entries"]: await self.repository.delete_cart_item(diff.uuid, entry.product.uuid) @@ -96,7 +96,7 @@ async def cart_item_updated(self, request: Request) -> None: :param request: A request instance containing the aggregate difference. :return: This method does not return anything. """ - diff: AggregateDiff = await request.content() + diff: Event = await request.content() for entry in diff["entries"]: await self.repository.update_cart_item( @@ -116,7 +116,7 @@ async def product_updated(self, request: Request) -> None: :param request: A request instance containing the aggregate difference. :return: This method does not return anything. """ - diff: AggregateDiff = await request.content() + diff: Event = await request.content() await self.repository.update_cart_items(uuid=diff.uuid, **diff.fields_diff) print(diff) @@ -126,7 +126,7 @@ async def cart_deleted(self, request: Request) -> None: :param request: A request instance containing the aggregate difference. :return: This method does not return anything. """ - diff: AggregateDiff = await request.content() + diff: Event = await request.content() cart_uuid = diff.uuid await self.repository.delete_cart(cart_uuid) diff --git a/microservices/customer/config.yml b/microservices/customer/config.yml index d6d5bfc1..bcacc749 100644 --- a/microservices/customer/config.yml +++ b/microservices/customer/config.yml @@ -4,8 +4,8 @@ service: injections: lock_pool: minos.common.PostgreSqlLockPool postgresql_pool: minos.common.PostgreSqlPool - broker_publisher: minos.networks.PostgreSqlQueuedKafkaBrokerPublisher - broker_subscriber_builder: minos.networks.PostgreSqlQueuedKafkaBrokerSubscriberBuilder + broker_publisher: minos.plugins.kafka.InMemoryQueuedKafkaBrokerPublisher + broker_subscriber_builder: minos.plugins.kafka.InMemoryQueuedKafkaBrokerSubscriberBuilder broker_pool: minos.networks.BrokerClientPool transaction_repository: minos.aggregate.PostgreSqlTransactionRepository event_repository: minos.aggregate.PostgreSqlEventRepository @@ -54,6 +54,6 @@ saga: storage: path: "./customer.lmdb" discovery: - client: minos.networks.MinosDiscoveryClient + client: minos.plugins.minos_discovery.MinosDiscoveryClient host: localhost port: 5567 \ No newline at end of file diff --git a/microservices/customer/poetry.lock b/microservices/customer/poetry.lock index 479bbf4e..5807e6e9 100644 --- a/microservices/customer/poetry.lock +++ b/microservices/customer/poetry.lock @@ -314,81 +314,140 @@ category = "dev" optional = false python-versions = "*" +[[package]] +name = "minos-broker-kafka" +version = "0.4.1" +description = "Minos Broker Kafka package" +category = "main" +optional = false +python-versions = "^3.9" +develop = true + +[package.dependencies] +aiokafka = "^0.7.0" +minos-microservice-common = "^0.4.0" +minos-microservice-networks = "^0.4.0" + +[package.source] +type = "directory" +url = "../../../minos-python/packages/plugins/minos-broker-kafka" + +[[package]] +name = "minos-discovery-minos" +version = "0.4.1" +description = "Minos Discovery Minos package" +category = "main" +optional = false +python-versions = "^3.9" +develop = true + +[package.dependencies] +minos-microservice-common = "^0.4.0" +minos-microservice-networks = "^0.4.0" + +[package.source] +type = "directory" +url = "../../../minos-python/packages/plugins/minos-discovery-minos" + [[package]] name = "minos-microservice-aggregate" -version = "0.4.0" -description = "Python Package for Minos Microservices containing all the Aggregate stuff" +version = "0.4.1" +description = "Python Package for Minos Microservices containing all the RootEntity stuff" category = "main" optional = false -python-versions = ">=3.9,<4.0" +python-versions = "^3.9" +develop = true [package.dependencies] -minos-microservice-common = ">=0.4.0,<0.5.0" -minos-microservice-networks = ">=0.4.0,<0.5.0" +minos-microservice-common = "^0.4.0" +minos-microservice-networks = "^0.4.0" + +[package.source] +type = "directory" +url = "../../../minos-python/packages/core/minos-microservice-aggregate" [[package]] name = "minos-microservice-common" -version = "0.4.0" +version = "0.4.1" description = "Python Package with common Classes and Utilities used in Minos Microservices." category = "main" optional = false -python-versions = ">=3.9,<4.0" +python-versions = "^3.9" +develop = true [package.dependencies] -aiomisc = ">=14.0.3,<15.0.0" -aiopg = ">=1.2.1,<2.0.0" -cached-property = ">=1.5.2,<2.0.0" -dependency-injector = ">=4.32.2,<5.0.0" -fastavro = ">=1.4.0,<2.0.0" -lmdb = ">=1.2.1,<2.0.0" -orjson = ">=3.5.2,<4.0.0" +aiomisc = "^14.0.3" +aiopg = "^1.2.1" +cached-property = "^1.5.2" +dependency-injector = "^4.32.2" +fastavro = "^1.4.0" +lmdb = "^1.2.1" +orjson = "^3.5.2" PyYAML = ">=5.4.1,<7.0.0" +[package.source] +type = "directory" +url = "../../../minos-python/packages/core/minos-microservice-common" + [[package]] name = "minos-microservice-cqrs" -version = "0.4.0" +version = "0.4.1" description = "Minos Microservice CQRS package" category = "main" optional = false -python-versions = ">=3.9,<4.0" +python-versions = "^3.9" +develop = true [package.dependencies] -dependency-injector = ">=4.34.0,<5.0.0" -minos-microservice-aggregate = ">=0.4.0,<0.5.0" -minos-microservice-common = ">=0.4.0,<0.5.0" -minos-microservice-networks = ">=0.4.0,<0.5.0" +dependency-injector = "^4.34.0" +minos-microservice-aggregate = "^0.4.0" +minos-microservice-common = "^0.4.0" +minos-microservice-networks = "^0.4.0" + +[package.source] +type = "directory" +url = "../../../minos-python/packages/core/minos-microservice-cqrs" [[package]] name = "minos-microservice-networks" -version = "0.4.0" +version = "0.4.1" description = "Python Package with the common network classes and utilities used in Minos Microservice." category = "main" optional = false -python-versions = ">=3.9,<4.0" +python-versions = "^3.9" +develop = true [package.dependencies] -aiohttp = ">=3.7.4,<4.0.0" -aiokafka = ">=0.7.0,<0.8.0" -aiomisc = ">=14.0.3,<15.0.0" -aiopg = ">=1.2.1,<2.0.0" -crontab = ">=0.23.0,<0.24.0" -dependency-injector = ">=4.32.2,<5.0.0" -minos-microservice-common = ">=0.4.0,<0.5.0" -orjson = ">=3.6.5,<4.0.0" +aiohttp = "^3.7.4" +aiomisc = "^14.0.3" +aiopg = "^1.2.1" +crontab = "^0.23.0" +dependency-injector = "^4.32.2" +minos-microservice-common = "^0.4.0" +orjson = "^3.6.5" + +[package.source] +type = "directory" +url = "../../../minos-python/packages/core/minos-microservice-networks" [[package]] name = "minos-microservice-saga" -version = "0.4.0" +version = "0.4.1" description = "Saga Library for MinOS project." category = "main" optional = false -python-versions = ">=3.9,<4.0" +python-versions = "^3.9" +develop = true [package.dependencies] -dependency-injector = ">=4.32.2,<5.0.0" -minos-microservice-aggregate = ">=0.4.0,<0.5.0" -minos-microservice-common = ">=0.4.0,<0.5.0" -minos-microservice-networks = ">=0.4.0,<0.5.0" +dependency-injector = "^4.32.2" +minos-microservice-aggregate = "^0.4.0" +minos-microservice-common = "^0.4.0" +minos-microservice-networks = "^0.4.0" + +[package.source] +type = "directory" +url = "../../../minos-python/packages/core/minos-microservice-saga" [[package]] name = "multidict" @@ -573,7 +632,7 @@ multidict = ">=4.0" [metadata] lock-version = "1.1" python-versions = "^3.9" -content-hash = "7da1d10e1e247f171e7b47edd4882cb7089e4579bf16637f6eabeb675c2cef18" +content-hash = "993b94cd6a1db223673a58f294c6c42b3b58cf97a9e96d9100ff20b005df81f3" [metadata.files] aiohttp = [ @@ -952,26 +1011,13 @@ mccabe = [ {file = "mccabe-0.6.1-py2.py3-none-any.whl", hash = "sha256:ab8a6258860da4b6677da4bd2fe5dc2c659cff31b3ee4f7f5d64e79735b80d42"}, {file = "mccabe-0.6.1.tar.gz", hash = "sha256:dd8d182285a0fe56bace7f45b5e7d1a6ebcbf524e8f3bd87eb0f125271b8831f"}, ] -minos-microservice-aggregate = [ - {file = "minos-microservice-aggregate-0.4.0.tar.gz", hash = "sha256:2ada8638f7bfec2c120df452648f438710d7e5dd63612d09c1ba7f8cb41ba23d"}, - {file = "minos_microservice_aggregate-0.4.0-py3-none-any.whl", hash = "sha256:9edcb9931f7aeb9a472b64259fd7d0c1363d9ea5ee59fc5282642748a1c76ed3"}, -] -minos-microservice-common = [ - {file = "minos-microservice-common-0.4.0.tar.gz", hash = "sha256:b74995fba27ca383e52804e2c0013350d747dcc03c38098ad2026a9cceb04996"}, - {file = "minos_microservice_common-0.4.0-py3-none-any.whl", hash = "sha256:65cecd809b243007d57740b7d40349544d6e98a69ce84aac86ca06a2a4b97e29"}, -] -minos-microservice-cqrs = [ - {file = "minos-microservice-cqrs-0.4.0.tar.gz", hash = "sha256:f494a4916b0ec4ad14e813e617ac307f895fa97d777e5fd457b1c5c3c45db471"}, - {file = "minos_microservice_cqrs-0.4.0-py3-none-any.whl", hash = "sha256:f6998cfb9cb870139f851166f6b0e0975af1ce3aac0171fe862260b9178c7f76"}, -] -minos-microservice-networks = [ - {file = "minos-microservice-networks-0.4.0.tar.gz", hash = "sha256:4aa1791a723e148bc06fcb15e39ac9bd852d54a5101dcf4f5e1d6a7b472b9888"}, - {file = "minos_microservice_networks-0.4.0-py3-none-any.whl", hash = "sha256:94ef940aa7c5a3f00127bed312ebea1c635be569c6500c81ce7914cbb5c4c7e9"}, -] -minos-microservice-saga = [ - {file = "minos-microservice-saga-0.4.0.tar.gz", hash = "sha256:6c1d7ff41261253512d1f1bb00a9d0c54b4b9860df470c71a424547fbe01638c"}, - {file = "minos_microservice_saga-0.4.0-py3-none-any.whl", hash = "sha256:2cb332de5e405243b71f38ed7453c0f6d692e96827bb76811595425383fad18b"}, -] +minos-broker-kafka = [] +minos-discovery-minos = [] +minos-microservice-aggregate = [] +minos-microservice-common = [] +minos-microservice-cqrs = [] +minos-microservice-networks = [] +minos-microservice-saga = [] multidict = [ {file = "multidict-6.0.2-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:0b9e95a740109c6047602f4db4da9949e6c5945cefbad34a1299775ddc9a62e2"}, {file = "multidict-6.0.2-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:ac0e27844758d7177989ce406acc6a83c16ed4524ebc363c1f748cba184d89d3"}, diff --git a/microservices/customer/pyproject.toml b/microservices/customer/pyproject.toml index 26060f0b..14c0ead5 100644 --- a/microservices/customer/pyproject.toml +++ b/microservices/customer/pyproject.toml @@ -7,11 +7,13 @@ packages = [{ include = "src" }] [tool.poetry.dependencies] python = "^3.9" -minos-microservice-common = "^0.4.0" -minos-microservice-networks = "^0.4.0" -minos-microservice-aggregate = "^0.4.0" -minos-microservice-saga = "^0.4.0" -minos-microservice-cqrs = "^0.4.0" +minos-microservice-common = { path = "../../../minos-python/packages/core/minos-microservice-common", develop = true } +minos-microservice-networks = { path = "../../../minos-python/packages/core/minos-microservice-networks", develop = true } +minos-microservice-aggregate = { path = "../../../minos-python/packages/core/minos-microservice-aggregate", develop = true } +minos-microservice-saga = { path = "../../../minos-python/packages/core/minos-microservice-saga", develop = true } +minos-microservice-cqrs = { path = "../../../minos-python/packages/core/minos-microservice-cqrs", develop = true } +minos-broker-kafka = { path = "../../../minos-python/packages/plugins/minos-broker-kafka", develop = true } +minos-discovery-minos = { path = "../../../minos-python/packages/plugins/minos-discovery-minos", develop = true } typer = "^0.3.2" [tool.poetry.dev-dependencies] diff --git a/microservices/customer/src/aggregates.py b/microservices/customer/src/aggregates.py index a2d04d9f..8b12152c 100644 --- a/microservices/customer/src/aggregates.py +++ b/microservices/customer/src/aggregates.py @@ -3,7 +3,7 @@ ) from minos.aggregate import ( - Aggregate, + RootEntity, ValueObject, ) @@ -13,8 +13,8 @@ class Address(ValueObject): street_no: int -class Customer(Aggregate): - """Customer Aggregate class.""" +class Customer(RootEntity): + """Customer RootEntity class.""" name: str surname: str diff --git a/microservices/customer/tests/test_commands/test_services.py b/microservices/customer/tests/test_commands/test_services.py index ce29e1f7..9ff2f84b 100644 --- a/microservices/customer/tests/test_commands/test_services.py +++ b/microservices/customer/tests/test_commands/test_services.py @@ -9,7 +9,7 @@ ) from minos.aggregate import ( - DeletedAggregateException, + AlreadyDeletedException, ) from minos.networks import ( InMemoryRequest, @@ -64,7 +64,7 @@ async def test_delete_customer(self): request = InMemoryRequest({"uuid": customer.uuid}) await self.service.delete_customer(request) - with self.assertRaises(DeletedAggregateException): + with self.assertRaises(AlreadyDeletedException): await Customer.get(customer.uuid) async def test_delete_customer_bad_request(self): diff --git a/microservices/order/config.yml b/microservices/order/config.yml index 9d5cb7f8..56b8494a 100644 --- a/microservices/order/config.yml +++ b/microservices/order/config.yml @@ -4,8 +4,8 @@ service: injections: lock_pool: minos.common.PostgreSqlLockPool postgresql_pool: minos.common.PostgreSqlPool - broker_publisher: minos.networks.PostgreSqlQueuedKafkaBrokerPublisher - broker_subscriber_builder: minos.networks.PostgreSqlQueuedKafkaBrokerSubscriberBuilder + broker_publisher: minos.plugins.kafka.InMemoryQueuedKafkaBrokerPublisher + broker_subscriber_builder: minos.plugins.kafka.InMemoryQueuedKafkaBrokerSubscriberBuilder broker_pool: minos.networks.BrokerClientPool transaction_repository: minos.aggregate.PostgreSqlTransactionRepository event_repository: minos.aggregate.PostgreSqlEventRepository @@ -55,6 +55,6 @@ saga: storage: path: "./order.lmdb" discovery: - client: minos.networks.MinosDiscoveryClient + client: minos.plugins.minos_discovery.MinosDiscoveryClient host: localhost port: 5567 diff --git a/microservices/order/poetry.lock b/microservices/order/poetry.lock index 678e8510..aeb22b46 100644 --- a/microservices/order/poetry.lock +++ b/microservices/order/poetry.lock @@ -325,81 +325,140 @@ category = "dev" optional = false python-versions = "*" +[[package]] +name = "minos-broker-kafka" +version = "0.4.1" +description = "Minos Broker Kafka package" +category = "main" +optional = false +python-versions = "^3.9" +develop = true + +[package.dependencies] +aiokafka = "^0.7.0" +minos-microservice-common = "^0.4.0" +minos-microservice-networks = "^0.4.0" + +[package.source] +type = "directory" +url = "../../../minos-python/packages/plugins/minos-broker-kafka" + +[[package]] +name = "minos-discovery-minos" +version = "0.4.1" +description = "Minos Discovery Minos package" +category = "main" +optional = false +python-versions = "^3.9" +develop = true + +[package.dependencies] +minos-microservice-common = "^0.4.0" +minos-microservice-networks = "^0.4.0" + +[package.source] +type = "directory" +url = "../../../minos-python/packages/plugins/minos-discovery-minos" + [[package]] name = "minos-microservice-aggregate" -version = "0.4.0" -description = "Python Package for Minos Microservices containing all the Aggregate stuff" +version = "0.4.1" +description = "Python Package for Minos Microservices containing all the RootEntity stuff" category = "main" optional = false -python-versions = ">=3.9,<4.0" +python-versions = "^3.9" +develop = true [package.dependencies] -minos-microservice-common = ">=0.4.0,<0.5.0" -minos-microservice-networks = ">=0.4.0,<0.5.0" +minos-microservice-common = "^0.4.0" +minos-microservice-networks = "^0.4.0" + +[package.source] +type = "directory" +url = "../../../minos-python/packages/core/minos-microservice-aggregate" [[package]] name = "minos-microservice-common" -version = "0.4.0" +version = "0.4.1" description = "Python Package with common Classes and Utilities used in Minos Microservices." category = "main" optional = false -python-versions = ">=3.9,<4.0" +python-versions = "^3.9" +develop = true [package.dependencies] -aiomisc = ">=14.0.3,<15.0.0" -aiopg = ">=1.2.1,<2.0.0" -cached-property = ">=1.5.2,<2.0.0" -dependency-injector = ">=4.32.2,<5.0.0" -fastavro = ">=1.4.0,<2.0.0" -lmdb = ">=1.2.1,<2.0.0" -orjson = ">=3.5.2,<4.0.0" +aiomisc = "^14.0.3" +aiopg = "^1.2.1" +cached-property = "^1.5.2" +dependency-injector = "^4.32.2" +fastavro = "^1.4.0" +lmdb = "^1.2.1" +orjson = "^3.5.2" PyYAML = ">=5.4.1,<7.0.0" +[package.source] +type = "directory" +url = "../../../minos-python/packages/core/minos-microservice-common" + [[package]] name = "minos-microservice-cqrs" -version = "0.4.0" +version = "0.4.1" description = "Minos Microservice CQRS package" category = "main" optional = false -python-versions = ">=3.9,<4.0" +python-versions = "^3.9" +develop = true [package.dependencies] -dependency-injector = ">=4.34.0,<5.0.0" -minos-microservice-aggregate = ">=0.4.0,<0.5.0" -minos-microservice-common = ">=0.4.0,<0.5.0" -minos-microservice-networks = ">=0.4.0,<0.5.0" +dependency-injector = "^4.34.0" +minos-microservice-aggregate = "^0.4.0" +minos-microservice-common = "^0.4.0" +minos-microservice-networks = "^0.4.0" + +[package.source] +type = "directory" +url = "../../../minos-python/packages/core/minos-microservice-cqrs" [[package]] name = "minos-microservice-networks" -version = "0.4.0" +version = "0.4.1" description = "Python Package with the common network classes and utilities used in Minos Microservice." category = "main" optional = false -python-versions = ">=3.9,<4.0" +python-versions = "^3.9" +develop = true [package.dependencies] -aiohttp = ">=3.7.4,<4.0.0" -aiokafka = ">=0.7.0,<0.8.0" -aiomisc = ">=14.0.3,<15.0.0" -aiopg = ">=1.2.1,<2.0.0" -crontab = ">=0.23.0,<0.24.0" -dependency-injector = ">=4.32.2,<5.0.0" -minos-microservice-common = ">=0.4.0,<0.5.0" -orjson = ">=3.6.5,<4.0.0" +aiohttp = "^3.7.4" +aiomisc = "^14.0.3" +aiopg = "^1.2.1" +crontab = "^0.23.0" +dependency-injector = "^4.32.2" +minos-microservice-common = "^0.4.0" +orjson = "^3.6.5" + +[package.source] +type = "directory" +url = "../../../minos-python/packages/core/minos-microservice-networks" [[package]] name = "minos-microservice-saga" -version = "0.4.0" +version = "0.4.1" description = "Saga Library for MinOS project." category = "main" optional = false -python-versions = ">=3.9,<4.0" +python-versions = "^3.9" +develop = true [package.dependencies] -dependency-injector = ">=4.32.2,<5.0.0" -minos-microservice-aggregate = ">=0.4.0,<0.5.0" -minos-microservice-common = ">=0.4.0,<0.5.0" -minos-microservice-networks = ">=0.4.0,<0.5.0" +dependency-injector = "^4.32.2" +minos-microservice-aggregate = "^0.4.0" +minos-microservice-common = "^0.4.0" +minos-microservice-networks = "^0.4.0" + +[package.source] +type = "directory" +url = "../../../minos-python/packages/core/minos-microservice-saga" [[package]] name = "multidict" @@ -615,7 +674,7 @@ multidict = ">=4.0" [metadata] lock-version = "1.1" python-versions = "^3.9" -content-hash = "f0df167ab7b6362ad3f88ffdc31707cacb7deecfdf8d601b764d7dea6da410ed" +content-hash = "65a271a969ca1dd6d6ca51030a421b889254bfac15e94872a304d1fdb4c292a8" [metadata.files] aiohttp = [ @@ -1051,26 +1110,13 @@ mccabe = [ {file = "mccabe-0.6.1-py2.py3-none-any.whl", hash = "sha256:ab8a6258860da4b6677da4bd2fe5dc2c659cff31b3ee4f7f5d64e79735b80d42"}, {file = "mccabe-0.6.1.tar.gz", hash = "sha256:dd8d182285a0fe56bace7f45b5e7d1a6ebcbf524e8f3bd87eb0f125271b8831f"}, ] -minos-microservice-aggregate = [ - {file = "minos-microservice-aggregate-0.4.0.tar.gz", hash = "sha256:2ada8638f7bfec2c120df452648f438710d7e5dd63612d09c1ba7f8cb41ba23d"}, - {file = "minos_microservice_aggregate-0.4.0-py3-none-any.whl", hash = "sha256:9edcb9931f7aeb9a472b64259fd7d0c1363d9ea5ee59fc5282642748a1c76ed3"}, -] -minos-microservice-common = [ - {file = "minos-microservice-common-0.4.0.tar.gz", hash = "sha256:b74995fba27ca383e52804e2c0013350d747dcc03c38098ad2026a9cceb04996"}, - {file = "minos_microservice_common-0.4.0-py3-none-any.whl", hash = "sha256:65cecd809b243007d57740b7d40349544d6e98a69ce84aac86ca06a2a4b97e29"}, -] -minos-microservice-cqrs = [ - {file = "minos-microservice-cqrs-0.4.0.tar.gz", hash = "sha256:f494a4916b0ec4ad14e813e617ac307f895fa97d777e5fd457b1c5c3c45db471"}, - {file = "minos_microservice_cqrs-0.4.0-py3-none-any.whl", hash = "sha256:f6998cfb9cb870139f851166f6b0e0975af1ce3aac0171fe862260b9178c7f76"}, -] -minos-microservice-networks = [ - {file = "minos-microservice-networks-0.4.0.tar.gz", hash = "sha256:4aa1791a723e148bc06fcb15e39ac9bd852d54a5101dcf4f5e1d6a7b472b9888"}, - {file = "minos_microservice_networks-0.4.0-py3-none-any.whl", hash = "sha256:94ef940aa7c5a3f00127bed312ebea1c635be569c6500c81ce7914cbb5c4c7e9"}, -] -minos-microservice-saga = [ - {file = "minos-microservice-saga-0.4.0.tar.gz", hash = "sha256:6c1d7ff41261253512d1f1bb00a9d0c54b4b9860df470c71a424547fbe01638c"}, - {file = "minos_microservice_saga-0.4.0-py3-none-any.whl", hash = "sha256:2cb332de5e405243b71f38ed7453c0f6d692e96827bb76811595425383fad18b"}, -] +minos-broker-kafka = [] +minos-discovery-minos = [] +minos-microservice-aggregate = [] +minos-microservice-common = [] +minos-microservice-cqrs = [] +minos-microservice-networks = [] +minos-microservice-saga = [] multidict = [ {file = "multidict-6.0.2-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:0b9e95a740109c6047602f4db4da9949e6c5945cefbad34a1299775ddc9a62e2"}, {file = "multidict-6.0.2-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:ac0e27844758d7177989ce406acc6a83c16ed4524ebc363c1f748cba184d89d3"}, diff --git a/microservices/order/pyproject.toml b/microservices/order/pyproject.toml index 6be7d59d..a1f32173 100644 --- a/microservices/order/pyproject.toml +++ b/microservices/order/pyproject.toml @@ -7,11 +7,13 @@ packages = [{ include = "src" }] [tool.poetry.dependencies] python = "^3.9" -minos-microservice-common = "^0.4.0" -minos-microservice-networks = "^0.4.0" -minos-microservice-aggregate = "^0.4.0" -minos-microservice-saga = "^0.4.0" -minos-microservice-cqrs = "^0.4.0" +minos-microservice-common = { path = "../../../minos-python/packages/core/minos-microservice-common", develop = true } +minos-microservice-networks = { path = "../../../minos-python/packages/core/minos-microservice-networks", develop = true } +minos-microservice-aggregate = { path = "../../../minos-python/packages/core/minos-microservice-aggregate", develop = true } +minos-microservice-saga = { path = "../../../minos-python/packages/core/minos-microservice-saga", develop = true } +minos-microservice-cqrs = { path = "../../../minos-python/packages/core/minos-microservice-cqrs", develop = true } +minos-broker-kafka = { path = "../../../minos-python/packages/plugins/minos-broker-kafka", develop = true } +minos-discovery-minos = { path = "../../../minos-python/packages/plugins/minos-discovery-minos", develop = true } typer = "^0.3.2" SQLAlchemy = "1.4.22" diff --git a/microservices/order/src/aggregates.py b/microservices/order/src/aggregates.py index f178ab9c..62b2c594 100644 --- a/microservices/order/src/aggregates.py +++ b/microservices/order/src/aggregates.py @@ -13,11 +13,11 @@ ) from minos.aggregate import ( - Aggregate, - AggregateRef, + RootEntity, + ExternalEntity, Entity, EntitySet, - ModelRef, + Ref, ValueObject, ) @@ -28,12 +28,12 @@ class OrderStatus(str, Enum): COMPLETED = "completed" -class Order(Aggregate): - """Order Aggregate class.""" +class Order(RootEntity): + """Order RootEntity class.""" - ticket: Optional[ModelRef[Ticket]] + ticket: Optional[Ref[Ticket]] - payment: Optional[ModelRef[Payment]] + payment: Optional[Ref[Payment]] payment_detail: PaymentDetail # TODO: Future Shipment Microservice @@ -45,11 +45,11 @@ class Order(Aggregate): created_at: datetime updated_at: datetime - customer: ModelRef[Customer] + customer: Ref[Customer] -class Ticket(AggregateRef): - """Ticket Aggregate class.""" +class Ticket(ExternalEntity): + """Ticket RootEntity class.""" total_price: float entries: EntitySet[TicketEntry] @@ -59,11 +59,11 @@ class TicketEntry(Entity): """Order Item class""" quantity: int - product: ModelRef[Product] + product: Ref[Product] -class Product(AggregateRef): - """Order AggregateRef class.""" +class Product(ExternalEntity): + """Order ExternalEntity class.""" title: str price: float @@ -76,8 +76,8 @@ class PaymentDetail(ValueObject): card_cvc: str -class Payment(AggregateRef): - """Payment AggregateRef class""" +class Payment(ExternalEntity): + """Payment ExternalEntity class""" status: str @@ -93,7 +93,7 @@ class ShipmentDetail(ValueObject): zip: int -class Customer(AggregateRef): +class Customer(ExternalEntity): """User class""" name: str diff --git a/microservices/order/src/queries/services.py b/microservices/order/src/queries/services.py index 3f1b90e6..03ded6d7 100644 --- a/microservices/order/src/queries/services.py +++ b/microservices/order/src/queries/services.py @@ -2,7 +2,7 @@ Provide, ) from minos.aggregate import ( - AggregateDiff, + Event, ) from minos.common import ( UUID_REGEX, @@ -79,7 +79,7 @@ async def order_created(self, request: Request) -> None: :param request: A request instance containing the aggregate difference. :return: This method does not return anything. """ - diff: AggregateDiff = await request.content() + diff: Event = await request.content() await self.repository.create( uuid=diff.uuid, version=diff.version, diff --git a/microservices/payment/config.yml b/microservices/payment/config.yml index ba692623..66cbf556 100644 --- a/microservices/payment/config.yml +++ b/microservices/payment/config.yml @@ -4,8 +4,8 @@ service: injections: lock_pool: minos.common.PostgreSqlLockPool postgresql_pool: minos.common.PostgreSqlPool - broker_publisher: minos.networks.PostgreSqlQueuedKafkaBrokerPublisher - broker_subscriber_builder: minos.networks.PostgreSqlQueuedKafkaBrokerSubscriberBuilder + broker_publisher: minos.plugins.kafka.InMemoryQueuedKafkaBrokerPublisher + broker_subscriber_builder: minos.plugins.kafka.InMemoryQueuedKafkaBrokerSubscriberBuilder broker_pool: minos.networks.BrokerClientPool transaction_repository: minos.aggregate.PostgreSqlTransactionRepository event_repository: minos.aggregate.PostgreSqlEventRepository @@ -55,6 +55,6 @@ saga: storage: path: "./payment.lmdb" discovery: - client: minos.networks.MinosDiscoveryClient + client: minos.plugins.minos_discovery.MinosDiscoveryClient host: localhost port: 5567 \ No newline at end of file diff --git a/microservices/payment/poetry.lock b/microservices/payment/poetry.lock index 479bbf4e..5807e6e9 100644 --- a/microservices/payment/poetry.lock +++ b/microservices/payment/poetry.lock @@ -314,81 +314,140 @@ category = "dev" optional = false python-versions = "*" +[[package]] +name = "minos-broker-kafka" +version = "0.4.1" +description = "Minos Broker Kafka package" +category = "main" +optional = false +python-versions = "^3.9" +develop = true + +[package.dependencies] +aiokafka = "^0.7.0" +minos-microservice-common = "^0.4.0" +minos-microservice-networks = "^0.4.0" + +[package.source] +type = "directory" +url = "../../../minos-python/packages/plugins/minos-broker-kafka" + +[[package]] +name = "minos-discovery-minos" +version = "0.4.1" +description = "Minos Discovery Minos package" +category = "main" +optional = false +python-versions = "^3.9" +develop = true + +[package.dependencies] +minos-microservice-common = "^0.4.0" +minos-microservice-networks = "^0.4.0" + +[package.source] +type = "directory" +url = "../../../minos-python/packages/plugins/minos-discovery-minos" + [[package]] name = "minos-microservice-aggregate" -version = "0.4.0" -description = "Python Package for Minos Microservices containing all the Aggregate stuff" +version = "0.4.1" +description = "Python Package for Minos Microservices containing all the RootEntity stuff" category = "main" optional = false -python-versions = ">=3.9,<4.0" +python-versions = "^3.9" +develop = true [package.dependencies] -minos-microservice-common = ">=0.4.0,<0.5.0" -minos-microservice-networks = ">=0.4.0,<0.5.0" +minos-microservice-common = "^0.4.0" +minos-microservice-networks = "^0.4.0" + +[package.source] +type = "directory" +url = "../../../minos-python/packages/core/minos-microservice-aggregate" [[package]] name = "minos-microservice-common" -version = "0.4.0" +version = "0.4.1" description = "Python Package with common Classes and Utilities used in Minos Microservices." category = "main" optional = false -python-versions = ">=3.9,<4.0" +python-versions = "^3.9" +develop = true [package.dependencies] -aiomisc = ">=14.0.3,<15.0.0" -aiopg = ">=1.2.1,<2.0.0" -cached-property = ">=1.5.2,<2.0.0" -dependency-injector = ">=4.32.2,<5.0.0" -fastavro = ">=1.4.0,<2.0.0" -lmdb = ">=1.2.1,<2.0.0" -orjson = ">=3.5.2,<4.0.0" +aiomisc = "^14.0.3" +aiopg = "^1.2.1" +cached-property = "^1.5.2" +dependency-injector = "^4.32.2" +fastavro = "^1.4.0" +lmdb = "^1.2.1" +orjson = "^3.5.2" PyYAML = ">=5.4.1,<7.0.0" +[package.source] +type = "directory" +url = "../../../minos-python/packages/core/minos-microservice-common" + [[package]] name = "minos-microservice-cqrs" -version = "0.4.0" +version = "0.4.1" description = "Minos Microservice CQRS package" category = "main" optional = false -python-versions = ">=3.9,<4.0" +python-versions = "^3.9" +develop = true [package.dependencies] -dependency-injector = ">=4.34.0,<5.0.0" -minos-microservice-aggregate = ">=0.4.0,<0.5.0" -minos-microservice-common = ">=0.4.0,<0.5.0" -minos-microservice-networks = ">=0.4.0,<0.5.0" +dependency-injector = "^4.34.0" +minos-microservice-aggregate = "^0.4.0" +minos-microservice-common = "^0.4.0" +minos-microservice-networks = "^0.4.0" + +[package.source] +type = "directory" +url = "../../../minos-python/packages/core/minos-microservice-cqrs" [[package]] name = "minos-microservice-networks" -version = "0.4.0" +version = "0.4.1" description = "Python Package with the common network classes and utilities used in Minos Microservice." category = "main" optional = false -python-versions = ">=3.9,<4.0" +python-versions = "^3.9" +develop = true [package.dependencies] -aiohttp = ">=3.7.4,<4.0.0" -aiokafka = ">=0.7.0,<0.8.0" -aiomisc = ">=14.0.3,<15.0.0" -aiopg = ">=1.2.1,<2.0.0" -crontab = ">=0.23.0,<0.24.0" -dependency-injector = ">=4.32.2,<5.0.0" -minos-microservice-common = ">=0.4.0,<0.5.0" -orjson = ">=3.6.5,<4.0.0" +aiohttp = "^3.7.4" +aiomisc = "^14.0.3" +aiopg = "^1.2.1" +crontab = "^0.23.0" +dependency-injector = "^4.32.2" +minos-microservice-common = "^0.4.0" +orjson = "^3.6.5" + +[package.source] +type = "directory" +url = "../../../minos-python/packages/core/minos-microservice-networks" [[package]] name = "minos-microservice-saga" -version = "0.4.0" +version = "0.4.1" description = "Saga Library for MinOS project." category = "main" optional = false -python-versions = ">=3.9,<4.0" +python-versions = "^3.9" +develop = true [package.dependencies] -dependency-injector = ">=4.32.2,<5.0.0" -minos-microservice-aggregate = ">=0.4.0,<0.5.0" -minos-microservice-common = ">=0.4.0,<0.5.0" -minos-microservice-networks = ">=0.4.0,<0.5.0" +dependency-injector = "^4.32.2" +minos-microservice-aggregate = "^0.4.0" +minos-microservice-common = "^0.4.0" +minos-microservice-networks = "^0.4.0" + +[package.source] +type = "directory" +url = "../../../minos-python/packages/core/minos-microservice-saga" [[package]] name = "multidict" @@ -573,7 +632,7 @@ multidict = ">=4.0" [metadata] lock-version = "1.1" python-versions = "^3.9" -content-hash = "7da1d10e1e247f171e7b47edd4882cb7089e4579bf16637f6eabeb675c2cef18" +content-hash = "993b94cd6a1db223673a58f294c6c42b3b58cf97a9e96d9100ff20b005df81f3" [metadata.files] aiohttp = [ @@ -952,26 +1011,13 @@ mccabe = [ {file = "mccabe-0.6.1-py2.py3-none-any.whl", hash = "sha256:ab8a6258860da4b6677da4bd2fe5dc2c659cff31b3ee4f7f5d64e79735b80d42"}, {file = "mccabe-0.6.1.tar.gz", hash = "sha256:dd8d182285a0fe56bace7f45b5e7d1a6ebcbf524e8f3bd87eb0f125271b8831f"}, ] -minos-microservice-aggregate = [ - {file = "minos-microservice-aggregate-0.4.0.tar.gz", hash = "sha256:2ada8638f7bfec2c120df452648f438710d7e5dd63612d09c1ba7f8cb41ba23d"}, - {file = "minos_microservice_aggregate-0.4.0-py3-none-any.whl", hash = "sha256:9edcb9931f7aeb9a472b64259fd7d0c1363d9ea5ee59fc5282642748a1c76ed3"}, -] -minos-microservice-common = [ - {file = "minos-microservice-common-0.4.0.tar.gz", hash = "sha256:b74995fba27ca383e52804e2c0013350d747dcc03c38098ad2026a9cceb04996"}, - {file = "minos_microservice_common-0.4.0-py3-none-any.whl", hash = "sha256:65cecd809b243007d57740b7d40349544d6e98a69ce84aac86ca06a2a4b97e29"}, -] -minos-microservice-cqrs = [ - {file = "minos-microservice-cqrs-0.4.0.tar.gz", hash = "sha256:f494a4916b0ec4ad14e813e617ac307f895fa97d777e5fd457b1c5c3c45db471"}, - {file = "minos_microservice_cqrs-0.4.0-py3-none-any.whl", hash = "sha256:f6998cfb9cb870139f851166f6b0e0975af1ce3aac0171fe862260b9178c7f76"}, -] -minos-microservice-networks = [ - {file = "minos-microservice-networks-0.4.0.tar.gz", hash = "sha256:4aa1791a723e148bc06fcb15e39ac9bd852d54a5101dcf4f5e1d6a7b472b9888"}, - {file = "minos_microservice_networks-0.4.0-py3-none-any.whl", hash = "sha256:94ef940aa7c5a3f00127bed312ebea1c635be569c6500c81ce7914cbb5c4c7e9"}, -] -minos-microservice-saga = [ - {file = "minos-microservice-saga-0.4.0.tar.gz", hash = "sha256:6c1d7ff41261253512d1f1bb00a9d0c54b4b9860df470c71a424547fbe01638c"}, - {file = "minos_microservice_saga-0.4.0-py3-none-any.whl", hash = "sha256:2cb332de5e405243b71f38ed7453c0f6d692e96827bb76811595425383fad18b"}, -] +minos-broker-kafka = [] +minos-discovery-minos = [] +minos-microservice-aggregate = [] +minos-microservice-common = [] +minos-microservice-cqrs = [] +minos-microservice-networks = [] +minos-microservice-saga = [] multidict = [ {file = "multidict-6.0.2-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:0b9e95a740109c6047602f4db4da9949e6c5945cefbad34a1299775ddc9a62e2"}, {file = "multidict-6.0.2-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:ac0e27844758d7177989ce406acc6a83c16ed4524ebc363c1f748cba184d89d3"}, diff --git a/microservices/payment/pyproject.toml b/microservices/payment/pyproject.toml index 14efb3f8..3c3cd57d 100644 --- a/microservices/payment/pyproject.toml +++ b/microservices/payment/pyproject.toml @@ -7,11 +7,13 @@ packages = [{ include = "src" }] [tool.poetry.dependencies] python = "^3.9" -minos-microservice-common = "^0.4.0" -minos-microservice-networks = "^0.4.0" -minos-microservice-aggregate = "^0.4.0" -minos-microservice-saga = "^0.4.0" -minos-microservice-cqrs = "^0.4.0" +minos-microservice-common = { path = "../../../minos-python/packages/core/minos-microservice-common", develop = true } +minos-microservice-networks = { path = "../../../minos-python/packages/core/minos-microservice-networks", develop = true } +minos-microservice-aggregate = { path = "../../../minos-python/packages/core/minos-microservice-aggregate", develop = true } +minos-microservice-saga = { path = "../../../minos-python/packages/core/minos-microservice-saga", develop = true } +minos-microservice-cqrs = { path = "../../../minos-python/packages/core/minos-microservice-cqrs", develop = true } +minos-broker-kafka = { path = "../../../minos-python/packages/plugins/minos-broker-kafka", develop = true } +minos-discovery-minos = { path = "../../../minos-python/packages/plugins/minos-discovery-minos", develop = true } typer = "^0.3.2" [tool.poetry.dev-dependencies] diff --git a/microservices/payment/src/aggregates.py b/microservices/payment/src/aggregates.py index 4cf8c779..bc2186ed 100644 --- a/microservices/payment/src/aggregates.py +++ b/microservices/payment/src/aggregates.py @@ -1,10 +1,10 @@ from minos.aggregate import ( - Aggregate, + RootEntity, ) -class Payment(Aggregate): - """Payment Aggregate class.""" +class Payment(RootEntity): + """Payment RootEntity class.""" credit_number: int amount: float diff --git a/microservices/payment/src/queries/services.py b/microservices/payment/src/queries/services.py index 1bff4114..e7fb55ce 100644 --- a/microservices/payment/src/queries/services.py +++ b/microservices/payment/src/queries/services.py @@ -2,7 +2,7 @@ Provide, ) from minos.aggregate import ( - AggregateDiff, + Event, ) from minos.cqrs import ( QueryService, @@ -30,7 +30,7 @@ async def payment_created_or_updated(self, request: Request) -> None: :param request: A request instance containing the aggregate difference. :return: This method does not return anything. """ - diff: AggregateDiff = await request.content() + diff: Event = await request.content() uuid = diff.uuid amount = diff["amount"] @@ -43,6 +43,6 @@ async def payment_deleted(self, request: Request) -> None: :param request: A request instance containing the aggregate difference. :return: This method does not return anything. """ - diff: AggregateDiff = await request.content() + diff: Event = await request.content() await self.repository.delete(diff.uuid) diff --git a/microservices/product/config.yml b/microservices/product/config.yml index 8b10cdc2..c6067663 100644 --- a/microservices/product/config.yml +++ b/microservices/product/config.yml @@ -4,8 +4,8 @@ service: injections: lock_pool: minos.common.PostgreSqlLockPool postgresql_pool: minos.common.PostgreSqlPool - broker_publisher: minos.networks.PostgreSqlQueuedKafkaBrokerPublisher - broker_subscriber_builder: minos.networks.PostgreSqlQueuedKafkaBrokerSubscriberBuilder + broker_publisher: minos.plugins.kafka.InMemoryQueuedKafkaBrokerPublisher + broker_subscriber_builder: minos.plugins.kafka.InMemoryQueuedKafkaBrokerSubscriberBuilder broker_pool: minos.networks.BrokerClientPool transaction_repository: minos.aggregate.PostgreSqlTransactionRepository event_repository: minos.aggregate.PostgreSqlEventRepository @@ -55,6 +55,6 @@ saga: storage: path: "./product.lmdb" discovery: - client: minos.networks.MinosDiscoveryClient + client: minos.plugins.minos_discovery.MinosDiscoveryClient host: localhost port: 5567 \ No newline at end of file diff --git a/microservices/product/poetry.lock b/microservices/product/poetry.lock index 678e8510..aeb22b46 100644 --- a/microservices/product/poetry.lock +++ b/microservices/product/poetry.lock @@ -325,81 +325,140 @@ category = "dev" optional = false python-versions = "*" +[[package]] +name = "minos-broker-kafka" +version = "0.4.1" +description = "Minos Broker Kafka package" +category = "main" +optional = false +python-versions = "^3.9" +develop = true + +[package.dependencies] +aiokafka = "^0.7.0" +minos-microservice-common = "^0.4.0" +minos-microservice-networks = "^0.4.0" + +[package.source] +type = "directory" +url = "../../../minos-python/packages/plugins/minos-broker-kafka" + +[[package]] +name = "minos-discovery-minos" +version = "0.4.1" +description = "Minos Discovery Minos package" +category = "main" +optional = false +python-versions = "^3.9" +develop = true + +[package.dependencies] +minos-microservice-common = "^0.4.0" +minos-microservice-networks = "^0.4.0" + +[package.source] +type = "directory" +url = "../../../minos-python/packages/plugins/minos-discovery-minos" + [[package]] name = "minos-microservice-aggregate" -version = "0.4.0" -description = "Python Package for Minos Microservices containing all the Aggregate stuff" +version = "0.4.1" +description = "Python Package for Minos Microservices containing all the RootEntity stuff" category = "main" optional = false -python-versions = ">=3.9,<4.0" +python-versions = "^3.9" +develop = true [package.dependencies] -minos-microservice-common = ">=0.4.0,<0.5.0" -minos-microservice-networks = ">=0.4.0,<0.5.0" +minos-microservice-common = "^0.4.0" +minos-microservice-networks = "^0.4.0" + +[package.source] +type = "directory" +url = "../../../minos-python/packages/core/minos-microservice-aggregate" [[package]] name = "minos-microservice-common" -version = "0.4.0" +version = "0.4.1" description = "Python Package with common Classes and Utilities used in Minos Microservices." category = "main" optional = false -python-versions = ">=3.9,<4.0" +python-versions = "^3.9" +develop = true [package.dependencies] -aiomisc = ">=14.0.3,<15.0.0" -aiopg = ">=1.2.1,<2.0.0" -cached-property = ">=1.5.2,<2.0.0" -dependency-injector = ">=4.32.2,<5.0.0" -fastavro = ">=1.4.0,<2.0.0" -lmdb = ">=1.2.1,<2.0.0" -orjson = ">=3.5.2,<4.0.0" +aiomisc = "^14.0.3" +aiopg = "^1.2.1" +cached-property = "^1.5.2" +dependency-injector = "^4.32.2" +fastavro = "^1.4.0" +lmdb = "^1.2.1" +orjson = "^3.5.2" PyYAML = ">=5.4.1,<7.0.0" +[package.source] +type = "directory" +url = "../../../minos-python/packages/core/minos-microservice-common" + [[package]] name = "minos-microservice-cqrs" -version = "0.4.0" +version = "0.4.1" description = "Minos Microservice CQRS package" category = "main" optional = false -python-versions = ">=3.9,<4.0" +python-versions = "^3.9" +develop = true [package.dependencies] -dependency-injector = ">=4.34.0,<5.0.0" -minos-microservice-aggregate = ">=0.4.0,<0.5.0" -minos-microservice-common = ">=0.4.0,<0.5.0" -minos-microservice-networks = ">=0.4.0,<0.5.0" +dependency-injector = "^4.34.0" +minos-microservice-aggregate = "^0.4.0" +minos-microservice-common = "^0.4.0" +minos-microservice-networks = "^0.4.0" + +[package.source] +type = "directory" +url = "../../../minos-python/packages/core/minos-microservice-cqrs" [[package]] name = "minos-microservice-networks" -version = "0.4.0" +version = "0.4.1" description = "Python Package with the common network classes and utilities used in Minos Microservice." category = "main" optional = false -python-versions = ">=3.9,<4.0" +python-versions = "^3.9" +develop = true [package.dependencies] -aiohttp = ">=3.7.4,<4.0.0" -aiokafka = ">=0.7.0,<0.8.0" -aiomisc = ">=14.0.3,<15.0.0" -aiopg = ">=1.2.1,<2.0.0" -crontab = ">=0.23.0,<0.24.0" -dependency-injector = ">=4.32.2,<5.0.0" -minos-microservice-common = ">=0.4.0,<0.5.0" -orjson = ">=3.6.5,<4.0.0" +aiohttp = "^3.7.4" +aiomisc = "^14.0.3" +aiopg = "^1.2.1" +crontab = "^0.23.0" +dependency-injector = "^4.32.2" +minos-microservice-common = "^0.4.0" +orjson = "^3.6.5" + +[package.source] +type = "directory" +url = "../../../minos-python/packages/core/minos-microservice-networks" [[package]] name = "minos-microservice-saga" -version = "0.4.0" +version = "0.4.1" description = "Saga Library for MinOS project." category = "main" optional = false -python-versions = ">=3.9,<4.0" +python-versions = "^3.9" +develop = true [package.dependencies] -dependency-injector = ">=4.32.2,<5.0.0" -minos-microservice-aggregate = ">=0.4.0,<0.5.0" -minos-microservice-common = ">=0.4.0,<0.5.0" -minos-microservice-networks = ">=0.4.0,<0.5.0" +dependency-injector = "^4.32.2" +minos-microservice-aggregate = "^0.4.0" +minos-microservice-common = "^0.4.0" +minos-microservice-networks = "^0.4.0" + +[package.source] +type = "directory" +url = "../../../minos-python/packages/core/minos-microservice-saga" [[package]] name = "multidict" @@ -615,7 +674,7 @@ multidict = ">=4.0" [metadata] lock-version = "1.1" python-versions = "^3.9" -content-hash = "f0df167ab7b6362ad3f88ffdc31707cacb7deecfdf8d601b764d7dea6da410ed" +content-hash = "65a271a969ca1dd6d6ca51030a421b889254bfac15e94872a304d1fdb4c292a8" [metadata.files] aiohttp = [ @@ -1051,26 +1110,13 @@ mccabe = [ {file = "mccabe-0.6.1-py2.py3-none-any.whl", hash = "sha256:ab8a6258860da4b6677da4bd2fe5dc2c659cff31b3ee4f7f5d64e79735b80d42"}, {file = "mccabe-0.6.1.tar.gz", hash = "sha256:dd8d182285a0fe56bace7f45b5e7d1a6ebcbf524e8f3bd87eb0f125271b8831f"}, ] -minos-microservice-aggregate = [ - {file = "minos-microservice-aggregate-0.4.0.tar.gz", hash = "sha256:2ada8638f7bfec2c120df452648f438710d7e5dd63612d09c1ba7f8cb41ba23d"}, - {file = "minos_microservice_aggregate-0.4.0-py3-none-any.whl", hash = "sha256:9edcb9931f7aeb9a472b64259fd7d0c1363d9ea5ee59fc5282642748a1c76ed3"}, -] -minos-microservice-common = [ - {file = "minos-microservice-common-0.4.0.tar.gz", hash = "sha256:b74995fba27ca383e52804e2c0013350d747dcc03c38098ad2026a9cceb04996"}, - {file = "minos_microservice_common-0.4.0-py3-none-any.whl", hash = "sha256:65cecd809b243007d57740b7d40349544d6e98a69ce84aac86ca06a2a4b97e29"}, -] -minos-microservice-cqrs = [ - {file = "minos-microservice-cqrs-0.4.0.tar.gz", hash = "sha256:f494a4916b0ec4ad14e813e617ac307f895fa97d777e5fd457b1c5c3c45db471"}, - {file = "minos_microservice_cqrs-0.4.0-py3-none-any.whl", hash = "sha256:f6998cfb9cb870139f851166f6b0e0975af1ce3aac0171fe862260b9178c7f76"}, -] -minos-microservice-networks = [ - {file = "minos-microservice-networks-0.4.0.tar.gz", hash = "sha256:4aa1791a723e148bc06fcb15e39ac9bd852d54a5101dcf4f5e1d6a7b472b9888"}, - {file = "minos_microservice_networks-0.4.0-py3-none-any.whl", hash = "sha256:94ef940aa7c5a3f00127bed312ebea1c635be569c6500c81ce7914cbb5c4c7e9"}, -] -minos-microservice-saga = [ - {file = "minos-microservice-saga-0.4.0.tar.gz", hash = "sha256:6c1d7ff41261253512d1f1bb00a9d0c54b4b9860df470c71a424547fbe01638c"}, - {file = "minos_microservice_saga-0.4.0-py3-none-any.whl", hash = "sha256:2cb332de5e405243b71f38ed7453c0f6d692e96827bb76811595425383fad18b"}, -] +minos-broker-kafka = [] +minos-discovery-minos = [] +minos-microservice-aggregate = [] +minos-microservice-common = [] +minos-microservice-cqrs = [] +minos-microservice-networks = [] +minos-microservice-saga = [] multidict = [ {file = "multidict-6.0.2-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:0b9e95a740109c6047602f4db4da9949e6c5945cefbad34a1299775ddc9a62e2"}, {file = "multidict-6.0.2-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:ac0e27844758d7177989ce406acc6a83c16ed4524ebc363c1f748cba184d89d3"}, diff --git a/microservices/product/pyproject.toml b/microservices/product/pyproject.toml index 54920167..0c6167dd 100644 --- a/microservices/product/pyproject.toml +++ b/microservices/product/pyproject.toml @@ -7,11 +7,13 @@ packages = [{ include = "src" }] [tool.poetry.dependencies] python = "^3.9" -minos-microservice-common = "^0.4.0" -minos-microservice-networks = "^0.4.0" -minos-microservice-aggregate = "^0.4.0" -minos-microservice-saga = "^0.4.0" -minos-microservice-cqrs = "^0.4.0" +minos-microservice-common = { path = "../../../minos-python/packages/core/minos-microservice-common", develop = true } +minos-microservice-networks = { path = "../../../minos-python/packages/core/minos-microservice-networks", develop = true } +minos-microservice-aggregate = { path = "../../../minos-python/packages/core/minos-microservice-aggregate", develop = true } +minos-microservice-saga = { path = "../../../minos-python/packages/core/minos-microservice-saga", develop = true } +minos-microservice-cqrs = { path = "../../../minos-python/packages/core/minos-microservice-cqrs", develop = true } +minos-broker-kafka = { path = "../../../minos-python/packages/plugins/minos-broker-kafka", develop = true } +minos-discovery-minos = { path = "../../../minos-python/packages/plugins/minos-discovery-minos", develop = true } typer = "^0.3.2" SQLAlchemy = "1.4.22" diff --git a/microservices/product/src/aggregates.py b/microservices/product/src/aggregates.py index b410e004..72651a51 100644 --- a/microservices/product/src/aggregates.py +++ b/microservices/product/src/aggregates.py @@ -10,12 +10,12 @@ ) from minos.aggregate import ( - Aggregate, + RootEntity, ValueObject, ) -class Product(Aggregate): +class Product(RootEntity): """Product class.""" code: str diff --git a/microservices/product/src/commands/services.py b/microservices/product/src/commands/services.py index 7ef38673..fe128d98 100644 --- a/microservices/product/src/commands/services.py +++ b/microservices/product/src/commands/services.py @@ -5,8 +5,8 @@ ) from minos.aggregate import ( - AggregateNotFoundException, - DeletedAggregateException, + NotFoundException, + AlreadyDeletedException, ) from minos.common import ( UUID_REGEX, @@ -176,7 +176,7 @@ async def delete_product(request: RestRequest) -> None: try: product = await Product.get(uuid) await product.delete() - except (DeletedAggregateException, AggregateNotFoundException): + except (AlreadyDeletedException, NotFoundException): raise ResponseException("The product does not exist.") @enroute.broker.command("ReserveProducts") @@ -192,7 +192,7 @@ async def reserve_products(self, request: Request) -> None: try: await Product.reserve(quantities) - except (AggregateNotFoundException, DeletedAggregateException) as exc: + except (NotFoundException, AlreadyDeletedException) as exc: raise ResponseException(f"Some products do not exist: {exc!r}") except Exception as exc: raise ResponseException(f"There is not enough product amount: {exc!r}") @@ -210,7 +210,7 @@ async def purchase_products(self, request: Request) -> None: try: await Product.purchase(quantities) - except (AggregateNotFoundException, DeletedAggregateException) as exc: + except (NotFoundException, AlreadyDeletedException) as exc: raise ResponseException(f"Some products do not exist: {exc!r}") except Exception as exc: raise ResponseException(f"There is not enough product amount: {exc!r}") diff --git a/microservices/product/src/queries/services.py b/microservices/product/src/queries/services.py index 0bb7d78a..07075e7e 100644 --- a/microservices/product/src/queries/services.py +++ b/microservices/product/src/queries/services.py @@ -2,7 +2,7 @@ Provide, ) from minos.aggregate import ( - AggregateDiff, + Event, ) from minos.common import ( UUID_REGEX, @@ -81,7 +81,7 @@ async def product_created(self, request: Request) -> None: :param request: A request instance containing the aggregate difference. :return: This method does not return anything. """ - diff: AggregateDiff = await request.content() + diff: Event = await request.content() await self.repository.create(uuid=diff.uuid, version=diff.version, **diff.fields_diff) @enroute.broker.event("ProductUpdated") @@ -91,7 +91,7 @@ async def product_updated(self, request: Request) -> None: :param request: A request instance containing the aggregate difference. :return: This method does not return anything. """ - diff: AggregateDiff = await request.content() + diff: Event = await request.content() await self.repository.update(uuid=diff.uuid, version=diff.version, **diff.fields_diff) @enroute.broker.event("ProductDeleted") @@ -101,7 +101,7 @@ async def product_deleted(self, request: Request) -> None: :param request: A request instance containing the aggregate difference. :return: This method does not return anything. """ - diff: AggregateDiff = await request.content() + diff: Event = await request.content() await self.repository.delete(diff.uuid) @enroute.broker.event("ReviewCreated") @@ -111,7 +111,7 @@ async def review_created(self, request: Request) -> None: :param request: A request instance containing the aggregate difference. :return: This method does not return anything. """ - diff: AggregateDiff = await request.content() + diff: Event = await request.content() await self.repository.update(uuid=diff.uuid, version=diff.version, **diff.fields_diff) @enroute.broker.event("ReviewUpdated.score") @@ -121,5 +121,5 @@ async def review_updated(self, request: Request) -> None: :param request: A request instance containing the aggregate difference. :return: This method does not return anything. """ - diff: AggregateDiff = await request.content() + diff: Event = await request.content() await self.repository.update(uuid=diff.uuid, version=diff.version, **diff.fields_diff) diff --git a/microservices/review/config.yml b/microservices/review/config.yml index 12e9df2c..f710fd40 100644 --- a/microservices/review/config.yml +++ b/microservices/review/config.yml @@ -4,8 +4,8 @@ service: injections: lock_pool: minos.common.PostgreSqlLockPool postgresql_pool: minos.common.PostgreSqlPool - broker_publisher: minos.networks.PostgreSqlQueuedKafkaBrokerPublisher - broker_subscriber_builder: minos.networks.PostgreSqlQueuedKafkaBrokerSubscriberBuilder + broker_publisher: minos.plugins.kafka.InMemoryQueuedKafkaBrokerPublisher + broker_subscriber_builder: minos.plugins.kafka.InMemoryQueuedKafkaBrokerSubscriberBuilder broker_pool: minos.networks.BrokerClientPool transaction_repository: minos.aggregate.PostgreSqlTransactionRepository event_repository: minos.aggregate.PostgreSqlEventRepository @@ -55,6 +55,6 @@ saga: storage: path: "./review.lmdb" discovery: - client: minos.networks.MinosDiscoveryClient + client: minos.plugins.minos_discovery.MinosDiscoveryClient host: localhost port: 5567 \ No newline at end of file diff --git a/microservices/review/poetry.lock b/microservices/review/poetry.lock index 678e8510..aeb22b46 100644 --- a/microservices/review/poetry.lock +++ b/microservices/review/poetry.lock @@ -325,81 +325,140 @@ category = "dev" optional = false python-versions = "*" +[[package]] +name = "minos-broker-kafka" +version = "0.4.1" +description = "Minos Broker Kafka package" +category = "main" +optional = false +python-versions = "^3.9" +develop = true + +[package.dependencies] +aiokafka = "^0.7.0" +minos-microservice-common = "^0.4.0" +minos-microservice-networks = "^0.4.0" + +[package.source] +type = "directory" +url = "../../../minos-python/packages/plugins/minos-broker-kafka" + +[[package]] +name = "minos-discovery-minos" +version = "0.4.1" +description = "Minos Discovery Minos package" +category = "main" +optional = false +python-versions = "^3.9" +develop = true + +[package.dependencies] +minos-microservice-common = "^0.4.0" +minos-microservice-networks = "^0.4.0" + +[package.source] +type = "directory" +url = "../../../minos-python/packages/plugins/minos-discovery-minos" + [[package]] name = "minos-microservice-aggregate" -version = "0.4.0" -description = "Python Package for Minos Microservices containing all the Aggregate stuff" +version = "0.4.1" +description = "Python Package for Minos Microservices containing all the RootEntity stuff" category = "main" optional = false -python-versions = ">=3.9,<4.0" +python-versions = "^3.9" +develop = true [package.dependencies] -minos-microservice-common = ">=0.4.0,<0.5.0" -minos-microservice-networks = ">=0.4.0,<0.5.0" +minos-microservice-common = "^0.4.0" +minos-microservice-networks = "^0.4.0" + +[package.source] +type = "directory" +url = "../../../minos-python/packages/core/minos-microservice-aggregate" [[package]] name = "minos-microservice-common" -version = "0.4.0" +version = "0.4.1" description = "Python Package with common Classes and Utilities used in Minos Microservices." category = "main" optional = false -python-versions = ">=3.9,<4.0" +python-versions = "^3.9" +develop = true [package.dependencies] -aiomisc = ">=14.0.3,<15.0.0" -aiopg = ">=1.2.1,<2.0.0" -cached-property = ">=1.5.2,<2.0.0" -dependency-injector = ">=4.32.2,<5.0.0" -fastavro = ">=1.4.0,<2.0.0" -lmdb = ">=1.2.1,<2.0.0" -orjson = ">=3.5.2,<4.0.0" +aiomisc = "^14.0.3" +aiopg = "^1.2.1" +cached-property = "^1.5.2" +dependency-injector = "^4.32.2" +fastavro = "^1.4.0" +lmdb = "^1.2.1" +orjson = "^3.5.2" PyYAML = ">=5.4.1,<7.0.0" +[package.source] +type = "directory" +url = "../../../minos-python/packages/core/minos-microservice-common" + [[package]] name = "minos-microservice-cqrs" -version = "0.4.0" +version = "0.4.1" description = "Minos Microservice CQRS package" category = "main" optional = false -python-versions = ">=3.9,<4.0" +python-versions = "^3.9" +develop = true [package.dependencies] -dependency-injector = ">=4.34.0,<5.0.0" -minos-microservice-aggregate = ">=0.4.0,<0.5.0" -minos-microservice-common = ">=0.4.0,<0.5.0" -minos-microservice-networks = ">=0.4.0,<0.5.0" +dependency-injector = "^4.34.0" +minos-microservice-aggregate = "^0.4.0" +minos-microservice-common = "^0.4.0" +minos-microservice-networks = "^0.4.0" + +[package.source] +type = "directory" +url = "../../../minos-python/packages/core/minos-microservice-cqrs" [[package]] name = "minos-microservice-networks" -version = "0.4.0" +version = "0.4.1" description = "Python Package with the common network classes and utilities used in Minos Microservice." category = "main" optional = false -python-versions = ">=3.9,<4.0" +python-versions = "^3.9" +develop = true [package.dependencies] -aiohttp = ">=3.7.4,<4.0.0" -aiokafka = ">=0.7.0,<0.8.0" -aiomisc = ">=14.0.3,<15.0.0" -aiopg = ">=1.2.1,<2.0.0" -crontab = ">=0.23.0,<0.24.0" -dependency-injector = ">=4.32.2,<5.0.0" -minos-microservice-common = ">=0.4.0,<0.5.0" -orjson = ">=3.6.5,<4.0.0" +aiohttp = "^3.7.4" +aiomisc = "^14.0.3" +aiopg = "^1.2.1" +crontab = "^0.23.0" +dependency-injector = "^4.32.2" +minos-microservice-common = "^0.4.0" +orjson = "^3.6.5" + +[package.source] +type = "directory" +url = "../../../minos-python/packages/core/minos-microservice-networks" [[package]] name = "minos-microservice-saga" -version = "0.4.0" +version = "0.4.1" description = "Saga Library for MinOS project." category = "main" optional = false -python-versions = ">=3.9,<4.0" +python-versions = "^3.9" +develop = true [package.dependencies] -dependency-injector = ">=4.32.2,<5.0.0" -minos-microservice-aggregate = ">=0.4.0,<0.5.0" -minos-microservice-common = ">=0.4.0,<0.5.0" -minos-microservice-networks = ">=0.4.0,<0.5.0" +dependency-injector = "^4.32.2" +minos-microservice-aggregate = "^0.4.0" +minos-microservice-common = "^0.4.0" +minos-microservice-networks = "^0.4.0" + +[package.source] +type = "directory" +url = "../../../minos-python/packages/core/minos-microservice-saga" [[package]] name = "multidict" @@ -615,7 +674,7 @@ multidict = ">=4.0" [metadata] lock-version = "1.1" python-versions = "^3.9" -content-hash = "f0df167ab7b6362ad3f88ffdc31707cacb7deecfdf8d601b764d7dea6da410ed" +content-hash = "65a271a969ca1dd6d6ca51030a421b889254bfac15e94872a304d1fdb4c292a8" [metadata.files] aiohttp = [ @@ -1051,26 +1110,13 @@ mccabe = [ {file = "mccabe-0.6.1-py2.py3-none-any.whl", hash = "sha256:ab8a6258860da4b6677da4bd2fe5dc2c659cff31b3ee4f7f5d64e79735b80d42"}, {file = "mccabe-0.6.1.tar.gz", hash = "sha256:dd8d182285a0fe56bace7f45b5e7d1a6ebcbf524e8f3bd87eb0f125271b8831f"}, ] -minos-microservice-aggregate = [ - {file = "minos-microservice-aggregate-0.4.0.tar.gz", hash = "sha256:2ada8638f7bfec2c120df452648f438710d7e5dd63612d09c1ba7f8cb41ba23d"}, - {file = "minos_microservice_aggregate-0.4.0-py3-none-any.whl", hash = "sha256:9edcb9931f7aeb9a472b64259fd7d0c1363d9ea5ee59fc5282642748a1c76ed3"}, -] -minos-microservice-common = [ - {file = "minos-microservice-common-0.4.0.tar.gz", hash = "sha256:b74995fba27ca383e52804e2c0013350d747dcc03c38098ad2026a9cceb04996"}, - {file = "minos_microservice_common-0.4.0-py3-none-any.whl", hash = "sha256:65cecd809b243007d57740b7d40349544d6e98a69ce84aac86ca06a2a4b97e29"}, -] -minos-microservice-cqrs = [ - {file = "minos-microservice-cqrs-0.4.0.tar.gz", hash = "sha256:f494a4916b0ec4ad14e813e617ac307f895fa97d777e5fd457b1c5c3c45db471"}, - {file = "minos_microservice_cqrs-0.4.0-py3-none-any.whl", hash = "sha256:f6998cfb9cb870139f851166f6b0e0975af1ce3aac0171fe862260b9178c7f76"}, -] -minos-microservice-networks = [ - {file = "minos-microservice-networks-0.4.0.tar.gz", hash = "sha256:4aa1791a723e148bc06fcb15e39ac9bd852d54a5101dcf4f5e1d6a7b472b9888"}, - {file = "minos_microservice_networks-0.4.0-py3-none-any.whl", hash = "sha256:94ef940aa7c5a3f00127bed312ebea1c635be569c6500c81ce7914cbb5c4c7e9"}, -] -minos-microservice-saga = [ - {file = "minos-microservice-saga-0.4.0.tar.gz", hash = "sha256:6c1d7ff41261253512d1f1bb00a9d0c54b4b9860df470c71a424547fbe01638c"}, - {file = "minos_microservice_saga-0.4.0-py3-none-any.whl", hash = "sha256:2cb332de5e405243b71f38ed7453c0f6d692e96827bb76811595425383fad18b"}, -] +minos-broker-kafka = [] +minos-discovery-minos = [] +minos-microservice-aggregate = [] +minos-microservice-common = [] +minos-microservice-cqrs = [] +minos-microservice-networks = [] +minos-microservice-saga = [] multidict = [ {file = "multidict-6.0.2-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:0b9e95a740109c6047602f4db4da9949e6c5945cefbad34a1299775ddc9a62e2"}, {file = "multidict-6.0.2-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:ac0e27844758d7177989ce406acc6a83c16ed4524ebc363c1f748cba184d89d3"}, diff --git a/microservices/review/pyproject.toml b/microservices/review/pyproject.toml index ed8cec51..6ae0f4b0 100644 --- a/microservices/review/pyproject.toml +++ b/microservices/review/pyproject.toml @@ -7,11 +7,13 @@ packages = [{ include = "src" }] [tool.poetry.dependencies] python = "^3.9" -minos-microservice-common = "^0.4.0" -minos-microservice-networks = "^0.4.0" -minos-microservice-aggregate = "^0.4.0" -minos-microservice-saga = "^0.4.0" -minos-microservice-cqrs = "^0.4.0" +minos-microservice-common = { path = "../../../minos-python/packages/core/minos-microservice-common", develop = true } +minos-microservice-networks = { path = "../../../minos-python/packages/core/minos-microservice-networks", develop = true } +minos-microservice-aggregate = { path = "../../../minos-python/packages/core/minos-microservice-aggregate", develop = true } +minos-microservice-saga = { path = "../../../minos-python/packages/core/minos-microservice-saga", develop = true } +minos-microservice-cqrs = { path = "../../../minos-python/packages/core/minos-microservice-cqrs", develop = true } +minos-broker-kafka = { path = "../../../minos-python/packages/plugins/minos-broker-kafka", develop = true } +minos-discovery-minos = { path = "../../../minos-python/packages/plugins/minos-discovery-minos", develop = true } typer = "^0.3.2" SQLAlchemy = "1.4.22" diff --git a/microservices/review/src/aggregates.py b/microservices/review/src/aggregates.py index 5fd19e4b..a56ebfd2 100644 --- a/microservices/review/src/aggregates.py +++ b/microservices/review/src/aggregates.py @@ -3,17 +3,17 @@ ) from minos.aggregate import ( - Aggregate, - AggregateRef, - ModelRef, + RootEntity, + ExternalEntity, + Ref, ) -class Review(Aggregate): +class Review(RootEntity): """Product Review class.""" - product: ModelRef[Product] - user: ModelRef[Customer] + product: Ref[Product] + user: Ref[Customer] title: str description: str score: int @@ -25,13 +25,13 @@ def validate_score(score: int) -> bool: return 1 <= score <= 5 -class Product(AggregateRef): - """Product AggregateRef class.""" +class Product(ExternalEntity): + """Product ExternalEntity class.""" title: str -class Customer(AggregateRef): - """Customer AggregateRef class.""" +class Customer(ExternalEntity): + """Customer ExternalEntity class.""" name: str diff --git a/microservices/review/src/queries/services.py b/microservices/review/src/queries/services.py index f0b1df0c..b7043441 100644 --- a/microservices/review/src/queries/services.py +++ b/microservices/review/src/queries/services.py @@ -2,7 +2,7 @@ Provide, ) from minos.aggregate import ( - AggregateDiff, + Event, ) from minos.cqrs import ( QueryService, @@ -133,7 +133,7 @@ async def review_created(self, request: Request) -> None: :param request: A request instance containing the aggregate difference. :return: This method does not return anything. """ - diff: AggregateDiff = await request.content() + diff: Event = await request.content() await self.repository.create(uuid=diff.uuid, version=diff.version, **diff.fields_diff) @enroute.broker.event("ReviewUpdated") @@ -143,7 +143,7 @@ async def review_updated(self, request: Request) -> None: :param request: A request instance containing the aggregate difference. :return: This method does not return anything. """ - diff: AggregateDiff = await request.content() + diff: Event = await request.content() await self.repository.update(uuid=diff.uuid, version=diff.version, **diff.fields_diff) @enroute.broker.event("ProductUpdated.title") @@ -153,7 +153,7 @@ async def product_title_updated(self, request: Request) -> None: :param request: A request instance containing the aggregate difference. :return: This method does not return anything. """ - diff: AggregateDiff = await request.content() + diff: Event = await request.content() print(diff) @enroute.broker.event("CustomerUpdated.name") @@ -163,5 +163,5 @@ async def username_updated(self, request: Request) -> None: :param request: A request instance containing the aggregate difference. :return: This method does not return anything. """ - diff: AggregateDiff = await request.content() + diff: Event = await request.content() print(diff) diff --git a/microservices/ticket/config.yml b/microservices/ticket/config.yml index c0fbbf25..b9d9f7cc 100644 --- a/microservices/ticket/config.yml +++ b/microservices/ticket/config.yml @@ -4,8 +4,8 @@ service: injections: lock_pool: minos.common.PostgreSqlLockPool postgresql_pool: minos.common.PostgreSqlPool - broker_publisher: minos.networks.PostgreSqlQueuedKafkaBrokerPublisher - broker_subscriber_builder: minos.networks.PostgreSqlQueuedKafkaBrokerSubscriberBuilder + broker_publisher: minos.plugins.kafka.InMemoryQueuedKafkaBrokerPublisher + broker_subscriber_builder: minos.plugins.kafka.InMemoryQueuedKafkaBrokerSubscriberBuilder broker_pool: minos.networks.BrokerClientPool transaction_repository: minos.aggregate.PostgreSqlTransactionRepository event_repository: minos.aggregate.PostgreSqlEventRepository @@ -55,6 +55,6 @@ saga: storage: path: "./ticket.lmdb" discovery: - client: minos.networks.MinosDiscoveryClient + client: minos.plugins.minos_discovery.MinosDiscoveryClient host: localhost port: 5567 diff --git a/microservices/ticket/poetry.lock b/microservices/ticket/poetry.lock index 678e8510..aeb22b46 100644 --- a/microservices/ticket/poetry.lock +++ b/microservices/ticket/poetry.lock @@ -325,81 +325,140 @@ category = "dev" optional = false python-versions = "*" +[[package]] +name = "minos-broker-kafka" +version = "0.4.1" +description = "Minos Broker Kafka package" +category = "main" +optional = false +python-versions = "^3.9" +develop = true + +[package.dependencies] +aiokafka = "^0.7.0" +minos-microservice-common = "^0.4.0" +minos-microservice-networks = "^0.4.0" + +[package.source] +type = "directory" +url = "../../../minos-python/packages/plugins/minos-broker-kafka" + +[[package]] +name = "minos-discovery-minos" +version = "0.4.1" +description = "Minos Discovery Minos package" +category = "main" +optional = false +python-versions = "^3.9" +develop = true + +[package.dependencies] +minos-microservice-common = "^0.4.0" +minos-microservice-networks = "^0.4.0" + +[package.source] +type = "directory" +url = "../../../minos-python/packages/plugins/minos-discovery-minos" + [[package]] name = "minos-microservice-aggregate" -version = "0.4.0" -description = "Python Package for Minos Microservices containing all the Aggregate stuff" +version = "0.4.1" +description = "Python Package for Minos Microservices containing all the RootEntity stuff" category = "main" optional = false -python-versions = ">=3.9,<4.0" +python-versions = "^3.9" +develop = true [package.dependencies] -minos-microservice-common = ">=0.4.0,<0.5.0" -minos-microservice-networks = ">=0.4.0,<0.5.0" +minos-microservice-common = "^0.4.0" +minos-microservice-networks = "^0.4.0" + +[package.source] +type = "directory" +url = "../../../minos-python/packages/core/minos-microservice-aggregate" [[package]] name = "minos-microservice-common" -version = "0.4.0" +version = "0.4.1" description = "Python Package with common Classes and Utilities used in Minos Microservices." category = "main" optional = false -python-versions = ">=3.9,<4.0" +python-versions = "^3.9" +develop = true [package.dependencies] -aiomisc = ">=14.0.3,<15.0.0" -aiopg = ">=1.2.1,<2.0.0" -cached-property = ">=1.5.2,<2.0.0" -dependency-injector = ">=4.32.2,<5.0.0" -fastavro = ">=1.4.0,<2.0.0" -lmdb = ">=1.2.1,<2.0.0" -orjson = ">=3.5.2,<4.0.0" +aiomisc = "^14.0.3" +aiopg = "^1.2.1" +cached-property = "^1.5.2" +dependency-injector = "^4.32.2" +fastavro = "^1.4.0" +lmdb = "^1.2.1" +orjson = "^3.5.2" PyYAML = ">=5.4.1,<7.0.0" +[package.source] +type = "directory" +url = "../../../minos-python/packages/core/minos-microservice-common" + [[package]] name = "minos-microservice-cqrs" -version = "0.4.0" +version = "0.4.1" description = "Minos Microservice CQRS package" category = "main" optional = false -python-versions = ">=3.9,<4.0" +python-versions = "^3.9" +develop = true [package.dependencies] -dependency-injector = ">=4.34.0,<5.0.0" -minos-microservice-aggregate = ">=0.4.0,<0.5.0" -minos-microservice-common = ">=0.4.0,<0.5.0" -minos-microservice-networks = ">=0.4.0,<0.5.0" +dependency-injector = "^4.34.0" +minos-microservice-aggregate = "^0.4.0" +minos-microservice-common = "^0.4.0" +minos-microservice-networks = "^0.4.0" + +[package.source] +type = "directory" +url = "../../../minos-python/packages/core/minos-microservice-cqrs" [[package]] name = "minos-microservice-networks" -version = "0.4.0" +version = "0.4.1" description = "Python Package with the common network classes and utilities used in Minos Microservice." category = "main" optional = false -python-versions = ">=3.9,<4.0" +python-versions = "^3.9" +develop = true [package.dependencies] -aiohttp = ">=3.7.4,<4.0.0" -aiokafka = ">=0.7.0,<0.8.0" -aiomisc = ">=14.0.3,<15.0.0" -aiopg = ">=1.2.1,<2.0.0" -crontab = ">=0.23.0,<0.24.0" -dependency-injector = ">=4.32.2,<5.0.0" -minos-microservice-common = ">=0.4.0,<0.5.0" -orjson = ">=3.6.5,<4.0.0" +aiohttp = "^3.7.4" +aiomisc = "^14.0.3" +aiopg = "^1.2.1" +crontab = "^0.23.0" +dependency-injector = "^4.32.2" +minos-microservice-common = "^0.4.0" +orjson = "^3.6.5" + +[package.source] +type = "directory" +url = "../../../minos-python/packages/core/minos-microservice-networks" [[package]] name = "minos-microservice-saga" -version = "0.4.0" +version = "0.4.1" description = "Saga Library for MinOS project." category = "main" optional = false -python-versions = ">=3.9,<4.0" +python-versions = "^3.9" +develop = true [package.dependencies] -dependency-injector = ">=4.32.2,<5.0.0" -minos-microservice-aggregate = ">=0.4.0,<0.5.0" -minos-microservice-common = ">=0.4.0,<0.5.0" -minos-microservice-networks = ">=0.4.0,<0.5.0" +dependency-injector = "^4.32.2" +minos-microservice-aggregate = "^0.4.0" +minos-microservice-common = "^0.4.0" +minos-microservice-networks = "^0.4.0" + +[package.source] +type = "directory" +url = "../../../minos-python/packages/core/minos-microservice-saga" [[package]] name = "multidict" @@ -615,7 +674,7 @@ multidict = ">=4.0" [metadata] lock-version = "1.1" python-versions = "^3.9" -content-hash = "f0df167ab7b6362ad3f88ffdc31707cacb7deecfdf8d601b764d7dea6da410ed" +content-hash = "65a271a969ca1dd6d6ca51030a421b889254bfac15e94872a304d1fdb4c292a8" [metadata.files] aiohttp = [ @@ -1051,26 +1110,13 @@ mccabe = [ {file = "mccabe-0.6.1-py2.py3-none-any.whl", hash = "sha256:ab8a6258860da4b6677da4bd2fe5dc2c659cff31b3ee4f7f5d64e79735b80d42"}, {file = "mccabe-0.6.1.tar.gz", hash = "sha256:dd8d182285a0fe56bace7f45b5e7d1a6ebcbf524e8f3bd87eb0f125271b8831f"}, ] -minos-microservice-aggregate = [ - {file = "minos-microservice-aggregate-0.4.0.tar.gz", hash = "sha256:2ada8638f7bfec2c120df452648f438710d7e5dd63612d09c1ba7f8cb41ba23d"}, - {file = "minos_microservice_aggregate-0.4.0-py3-none-any.whl", hash = "sha256:9edcb9931f7aeb9a472b64259fd7d0c1363d9ea5ee59fc5282642748a1c76ed3"}, -] -minos-microservice-common = [ - {file = "minos-microservice-common-0.4.0.tar.gz", hash = "sha256:b74995fba27ca383e52804e2c0013350d747dcc03c38098ad2026a9cceb04996"}, - {file = "minos_microservice_common-0.4.0-py3-none-any.whl", hash = "sha256:65cecd809b243007d57740b7d40349544d6e98a69ce84aac86ca06a2a4b97e29"}, -] -minos-microservice-cqrs = [ - {file = "minos-microservice-cqrs-0.4.0.tar.gz", hash = "sha256:f494a4916b0ec4ad14e813e617ac307f895fa97d777e5fd457b1c5c3c45db471"}, - {file = "minos_microservice_cqrs-0.4.0-py3-none-any.whl", hash = "sha256:f6998cfb9cb870139f851166f6b0e0975af1ce3aac0171fe862260b9178c7f76"}, -] -minos-microservice-networks = [ - {file = "minos-microservice-networks-0.4.0.tar.gz", hash = "sha256:4aa1791a723e148bc06fcb15e39ac9bd852d54a5101dcf4f5e1d6a7b472b9888"}, - {file = "minos_microservice_networks-0.4.0-py3-none-any.whl", hash = "sha256:94ef940aa7c5a3f00127bed312ebea1c635be569c6500c81ce7914cbb5c4c7e9"}, -] -minos-microservice-saga = [ - {file = "minos-microservice-saga-0.4.0.tar.gz", hash = "sha256:6c1d7ff41261253512d1f1bb00a9d0c54b4b9860df470c71a424547fbe01638c"}, - {file = "minos_microservice_saga-0.4.0-py3-none-any.whl", hash = "sha256:2cb332de5e405243b71f38ed7453c0f6d692e96827bb76811595425383fad18b"}, -] +minos-broker-kafka = [] +minos-discovery-minos = [] +minos-microservice-aggregate = [] +minos-microservice-common = [] +minos-microservice-cqrs = [] +minos-microservice-networks = [] +minos-microservice-saga = [] multidict = [ {file = "multidict-6.0.2-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:0b9e95a740109c6047602f4db4da9949e6c5945cefbad34a1299775ddc9a62e2"}, {file = "multidict-6.0.2-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:ac0e27844758d7177989ce406acc6a83c16ed4524ebc363c1f748cba184d89d3"}, diff --git a/microservices/ticket/pyproject.toml b/microservices/ticket/pyproject.toml index a45be563..563764e1 100644 --- a/microservices/ticket/pyproject.toml +++ b/microservices/ticket/pyproject.toml @@ -7,11 +7,13 @@ packages = [{ include = "src" }] [tool.poetry.dependencies] python = "^3.9" -minos-microservice-common = "^0.4.0" -minos-microservice-networks = "^0.4.0" -minos-microservice-aggregate = "^0.4.0" -minos-microservice-saga = "^0.4.0" -minos-microservice-cqrs = "^0.4.0" +minos-microservice-common = { path = "../../../minos-python/packages/core/minos-microservice-common", develop = true } +minos-microservice-networks = { path = "../../../minos-python/packages/core/minos-microservice-networks", develop = true } +minos-microservice-aggregate = { path = "../../../minos-python/packages/core/minos-microservice-aggregate", develop = true } +minos-microservice-saga = { path = "../../../minos-python/packages/core/minos-microservice-saga", develop = true } +minos-microservice-cqrs = { path = "../../../minos-python/packages/core/minos-microservice-cqrs", develop = true } +minos-broker-kafka = { path = "../../../minos-python/packages/plugins/minos-broker-kafka", develop = true } +minos-discovery-minos = { path = "../../../minos-python/packages/plugins/minos-discovery-minos", develop = true } typer = "^0.3.2" SQLAlchemy = "1.4.22" diff --git a/microservices/ticket/src/aggregates.py b/microservices/ticket/src/aggregates.py index c8a0652e..bc0ca32b 100644 --- a/microservices/ticket/src/aggregates.py +++ b/microservices/ticket/src/aggregates.py @@ -3,16 +3,16 @@ ) from minos.aggregate import ( - Aggregate, - AggregateRef, + RootEntity, + ExternalEntity, Entity, EntitySet, - ModelRef, + Ref, ) -class Ticket(Aggregate): - """Ticket Aggregate class.""" +class Ticket(RootEntity): + """Ticket RootEntity class.""" code: str total_price: float @@ -25,11 +25,11 @@ class TicketEntry(Entity): title: str unit_price: float quantity: int - product: ModelRef[Product] + product: Ref[Product] -class Product(AggregateRef): - """Order AggregateRef class.""" +class Product(ExternalEntity): + """Order ExternalEntity class.""" title: str price: float diff --git a/microservices/ticket/src/queries/services.py b/microservices/ticket/src/queries/services.py index c4ec4335..946435be 100644 --- a/microservices/ticket/src/queries/services.py +++ b/microservices/ticket/src/queries/services.py @@ -2,7 +2,7 @@ Provide, ) from minos.aggregate import ( - AggregateDiff, + Event, ) from minos.common import ( UUID_REGEX, @@ -52,7 +52,7 @@ async def ticket_created_or_updated(self, request: Request) -> None: :param request: A request instance containing the aggregate difference. :return: This method does not return anything. """ - diff: AggregateDiff = await request.content() + diff: Event = await request.content() uuid = diff.uuid version = diff["version"] code = diff["code"] @@ -67,6 +67,6 @@ async def ticket_deleted(self, request: Request) -> None: :param request: A request instance containing the aggregate difference. :return: This method does not return anything. """ - diff: AggregateDiff = await request.content() + diff: Event = await request.content() print(diff)