Skip to content

Commit

Permalink
Merge pull request #461 from minos-framework/0.8.0
Browse files Browse the repository at this point in the history
0.8.0.dev1
  • Loading branch information
Sergio García Prado committed May 12, 2022
2 parents f9f6ae4 + fc8baa0 commit a98f917
Show file tree
Hide file tree
Showing 229 changed files with 6,025 additions and 3,188 deletions.
1 change: 1 addition & 0 deletions .github/workflows/minos-database-aiopg-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ on:
- 'packages/plugins/minos-database-aiopg/**'
- 'packages/core/minos-microservice-aggregate/**'
- 'packages/core/minos-microservice-networks/**'
- 'packages/core/minos-microservice-transactions/**'
- 'packages/core/minos-microservice-common/**'

jobs:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/minos-microservice-aggregate-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ on:
paths:
- 'packages/core/minos-microservice-aggregate/**'
- 'packages/core/minos-microservice-networks/**'
- 'packages/core/minos-microservice-transactions/**'
- 'packages/core/minos-microservice-common/**'

jobs:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/minos-microservice-networks-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ on:
pull_request:
paths:
- 'packages/core/minos-microservice-networks/**'
- 'packages/core/minos-microservice-transactions/**'
- 'packages/core/minos-microservice-common/**'

jobs:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/minos-microservice-saga-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
paths:
- 'packages/core/minos-microservice-saga/**'
- 'packages/core/minos-microservice-networks/**'
- 'packages/core/minos-microservice-aggregate/**'
- 'packages/core/minos-microservice-transactions/**'
- 'packages/core/minos-microservice-common/**'

jobs:
Expand Down
33 changes: 33 additions & 0 deletions .github/workflows/minos-microservice-transactions-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: "Publish: minos-microservice-transactions"

on:
push:
branches:
- '*.*.x'
paths:
- 'packages/core/minos-microservice-transactions/**'

jobs:
deploy:
runs-on: ubuntu-latest
container: python:3.9-buster
defaults:
run:
working-directory: packages/core/minos-microservice-transactions

steps:

- name: Check out repository code
uses: actions/checkout@v2

- name: Install Poetry
uses: snok/install-poetry@v1

- name: Install dependencies
run: make install

- name: Publish package
run: make release
env:
POETRY_HTTP_BASIC_PYPI_USERNAME: ${{ secrets.PYPI_USERNAME }}
POETRY_HTTP_BASIC_PYPI_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
48 changes: 48 additions & 0 deletions .github/workflows/minos-microservice-transactions-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: "Test: minos-microservice-transactions"

on:
push:
branches:
- main
- '*.*.x'
pull_request:
paths:
- 'packages/core/minos-microservice-transactions/**'
- 'packages/core/minos-microservice-common/**'

jobs:
build:
runs-on: ubuntu-latest
container: python:3.9-buster
defaults:
run:
working-directory: packages/core/minos-microservice-transactions

steps:
- name: Check out repository code
uses: actions/checkout@v2

- name: Install Poetry
uses: snok/install-poetry@v1

- name: Install dependencies
run: make install

- name: Lint package
run: make lint

- name: Test package with coverage
run: make coverage

- name: Publish coverage
uses: codecov/codecov-action@v2
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./packages/core/minos-microservice-transactions/coverage.xml
fail_ci_if_error: true

- name: Generate documentation
run: make docs

- name: Generate build
run: make dist
7 changes: 7 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@ repos:
files: ^packages/core/minos-microservice-saga/
language: system

- id: minos-microservice-transactions-check
pass_filenames: false
entry: make --directory=packages/core/minos-microservice-transactions check
name: Check minos-microservice-transactions
files: ^packages/core/minos-microservice-transactions/
language: system

- id: minos-broker-kafka-check
pass_filenames: false
entry: make --directory=packages/plugins/minos-broker-kafka check
Expand Down
88 changes: 28 additions & 60 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -225,13 +225,13 @@ Create a `foo/main.py` file and add the following content:
# foo/main.py

from pathlib import Path
from minos.aggregate import Aggregate, RootEntity
from minos.aggregate import Aggregate, Entity
from minos.common import EntrypointLauncher
from minos.cqrs import CommandService, QueryService


class Foo(RootEntity):
"""Foo RootEntity class."""
class Foo(Entity):
"""Foo Entity class."""


class FooAggregate(Aggregate[Foo]):
Expand Down Expand Up @@ -262,14 +262,12 @@ python foo/main.py
The way to model data in `minos` is highly inspired by the [Event Sourcing](https://microservices.io/patterns/data/event-sourcing.html) ideas. For this reason, the classes to be used to model data are:

* `minos.aggregate.Entity`: A model that has an identifier that gives it a unique identity, in the sense that some values from which it is composed could change, but its identity will continue being the same.
* `minos.aggregate.ExternalEntity`: A model that belongs to another microservice (or aggregate boundary) but needs to be used for some reason inside this microservice (or aggregate boundary).
* `minos.aggregate.RootEntity`: Is an `Entity` superset that provides global identity across the project compared to standard `Entity` models, that has only local identity (the `RootEntity` can be accessed from another microservices as `ExternalEntity` models, but standard `Entity` models can only be accessed within the microservice that define them). The `RootEntity` is also the one that interacts with the persistence layer (the `EventRepository` and `SnapshotRepository` instances).
* `minos.aggregate.Ref`: A wrapper class that provides the functionality to store a reference of other `RootEntity` or `ExternalEntity` instances.
* `minos.aggregate.Ref`: A wrapper class that provides the functionality to store a reference of other `Entity` instances.
* `minos.aggregate.EntitySet`: A container of `Entity` instances that takes advantage of the incremental behaviour of the `EventRepository`.
* `minos.aggregate.ValueObject`: A model that is only identified by the values that compose it, so that if some of them changes, then the model becomes completely different (for that reason, these models are immutable).
* `minos.aggregate.ValueObjectSet`: A container of `ValueObject` instances that takes advantage of the incremental behaviour of the `EventRepository.
* `minos.aggregate.Aggregate`: A collection of `Entity` and/or `ValueObject` models that are related to each other through a `RootEntity`.
* `minos.aggregate.Event`: A model that contains the difference between the a `RootEntity` instance and its previous version (if any).
* `minos.aggregate.Aggregate`: A collection of `Entity` and/or `ValueObject` models that are related to each other through a special `Entity` known as the Root Entity of the Aggregate.
* `minos.aggregate.Event`: A model that contains the difference between the a `Entity` instance and its previous version (if any).

Here is an example of the creation the `Foo` aggregate. In this case, it has two attributes, a `bar` being a `str`, and a `foobar` being an optional reference to the external `FooBar` aggregate, which it is assumed that it has a `something` attribute.

Expand All @@ -279,20 +277,14 @@ Here is an example of the creation the `Foo` aggregate. In this case, it has two
from __future__ import annotations
from typing import Optional
from uuid import UUID
from minos.aggregate import Aggregate, RootEntity, ExternalEntity, Ref
from minos.aggregate import Aggregate, Entity, Ref


class Foo(RootEntity):
"""Foo RootEntity class."""
class Foo(Entity):
"""Foo Entity class."""

bar: str
foobar: Optional[Ref[FooBar]]


class FooBar(ExternalEntity):
"""FooBar ExternalEntity clas."""

something: str
foobar: Optional[Ref["FooBar"]]


class FooAggregate(Aggregate[Foo]):
Expand Down Expand Up @@ -334,22 +326,16 @@ from pathlib import Path
from typing import Optional
from uuid import UUID

from minos.aggregate import Aggregate, RootEntity, ExternalEntity, Ref
from minos.aggregate import Aggregate, Entity, Ref
from minos.common import EntrypointLauncher
from minos.cqrs import CommandService, QueryService


class Foo(RootEntity):
"""Foo RootEntity class."""
class Foo(Entity):
"""Foo Entity class."""

bar: str
foobar: Optional[Ref[FooBar]]


class FooBar(ExternalEntity):
"""FooBar ExternalEntity clas."""

something: str
foobar: Optional[Ref["FooBar"]]


class FooAggregate(Aggregate[Foo]):
Expand Down Expand Up @@ -436,23 +422,17 @@ from pathlib import Path
from typing import Optional
from uuid import UUID

from minos.aggregate import Aggregate, RootEntity, ExternalEntity, Ref
from minos.aggregate import Aggregate, Entity, Ref
from minos.common import EntrypointLauncher
from minos.cqrs import CommandService, QueryService
from minos.networks import Request, Response, enroute


class Foo(RootEntity):
"""Foo RootEntity class."""
class Foo(Entity):
"""Foo Entity class."""

bar: str
foobar: Optional[Ref[FooBar]]


class FooBar(ExternalEntity):
"""FooBar ExternalEntity clas."""

something: str
foobar: Optional[Ref["FooBar"]]


class FooAggregate(Aggregate[Foo]):
Expand Down Expand Up @@ -594,23 +574,17 @@ from pathlib import Path
from typing import Optional
from uuid import UUID

from minos.aggregate import Aggregate, RootEntity, ExternalEntity, Ref
from minos.aggregate import Aggregate, Entity, Ref
from minos.common import EntrypointLauncher
from minos.cqrs import CommandService, QueryService
from minos.networks import Request, Response, enroute


class Foo(RootEntity):
"""Foo RootEntity class."""
class Foo(Entity):
"""Foo Entity class."""

bar: str
foobar: Optional[Ref[FooBar]]


class FooBar(ExternalEntity):
"""FooBar ExternalEntity clas."""

something: str
foobar: Optional[Ref["FooBar"]]


class FooAggregate(Aggregate[Foo]):
Expand Down Expand Up @@ -797,24 +771,18 @@ from pathlib import Path
from typing import Optional
from uuid import UUID

from minos.aggregate import Aggregate, RootEntity, ExternalEntity, Ref
from minos.aggregate import Aggregate, Entity, Ref
from minos.common import ModelType, EntrypointLauncher
from minos.cqrs import CommandService, QueryService
from minos.networks import Request, Response, enroute
from minos.saga import Saga, SagaContext, SagaRequest, SagaResponse


class Foo(RootEntity):
"""Foo RootEntity class."""
class Foo(Entity):
"""Foo Entity class."""

bar: str
foobar: Optional[Ref[FooBar]]


class FooBar(ExternalEntity):
"""FooBar ExternalEntity clas."""

something: str
foobar: Optional[Ref["FooBar"]]


class FooAggregate(Aggregate[Foo]):
Expand Down Expand Up @@ -1046,13 +1014,13 @@ from __future__ import annotations
from pathlib import Path
from uuid import UUID

from minos.aggregate import Aggregate, RootEntity
from minos.aggregate import Aggregate, Entity
from minos.common import EntrypointLauncher
from minos.cqrs import CommandService
from minos.networks import Request, Response, enroute


class FooBar(RootEntity):
class FooBar(Entity):
"""FooBar Root Entity clas."""

something: str
Expand Down
Loading

0 comments on commit a98f917

Please sign in to comment.