Skip to content

Commit 883906e

Browse files
author
Sergio García Prado
committed
Merge remote-tracking branch 'origin/0.6.0' into issue-151-publish-api-specs
2 parents 3ee48ab + 7727757 commit 883906e

File tree

331 files changed

+13848
-1910
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

331 files changed

+13848
-1910
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: "Publish: minos-router-graphql"
2+
3+
on:
4+
push:
5+
branches:
6+
- '*.*.x'
7+
paths:
8+
- 'packages/plugins/minos-router-graphql/**'
9+
10+
jobs:
11+
deploy:
12+
runs-on: ubuntu-latest
13+
container: python:3.9-buster
14+
defaults:
15+
run:
16+
working-directory: packages/plugins/minos-router-graphql
17+
18+
steps:
19+
20+
- name: Check out repository code
21+
uses: actions/checkout@v2
22+
23+
- name: Install Poetry
24+
uses: snok/install-poetry@v1
25+
26+
- name: Install dependencies
27+
run: make install
28+
29+
- name: Publish package
30+
run: make release
31+
env:
32+
POETRY_HTTP_BASIC_PYPI_USERNAME: ${{ secrets.PYPI_USERNAME }}
33+
POETRY_HTTP_BASIC_PYPI_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: "Test: minos-router-graphql"
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- '*.*.x'
8+
pull_request:
9+
paths:
10+
- 'packages/plugins/minos-router-graphql/**'
11+
- 'packages/core/minos-microservice-networks/**'
12+
- 'packages/core/minos-microservice-common/**'
13+
14+
jobs:
15+
build:
16+
runs-on: ubuntu-latest
17+
container: python:3.9-buster
18+
defaults:
19+
run:
20+
working-directory: packages/plugins/minos-router-graphql
21+
22+
services:
23+
postgres:
24+
image: postgres
25+
env:
26+
POSTGRES_USER: minos
27+
POSTGRES_PASSWORD: min0s
28+
POSTGRES_DB: order_db
29+
ports:
30+
- 5432:5432
31+
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
32+
33+
env:
34+
MINOS_BROKER_QUEUE_HOST: postgres
35+
MINOS_BROKER_HOST: kafka
36+
MINOS_REPOSITORY_HOST: postgres
37+
MINOS_SNAPSHOT_HOST: postgres
38+
39+
steps:
40+
- name: Check out repository code
41+
uses: actions/checkout@v2
42+
43+
- name: Install Poetry
44+
uses: snok/install-poetry@v1
45+
46+
- name: Install dependencies
47+
run: make install
48+
49+
- name: Lint package
50+
run: make lint
51+
52+
- name: Test package with coverage
53+
run: make coverage
54+
55+
- name: Publish coverage
56+
uses: codecov/codecov-action@v2
57+
with:
58+
token: ${{ secrets.CODECOV_TOKEN }}
59+
files: ./packages/plugins/minos-router-graphql/coverage.xml
60+
fail_ci_if_error: true
61+
62+
- name: Generate documentation
63+
run: make docs
64+
65+
- name: Generate build
66+
run: make dist

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,3 +325,5 @@ $RECYCLE.BIN/
325325
# Sphinx Api Documentation
326326
**/docs/api*
327327
**/docs/_build
328+
329+
tutorials/stock-wallet/stacks

.pre-commit-config.yaml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,16 +44,23 @@ repos:
4444
files: ^packages/plugins/minos-broker-kafka/
4545
language: system
4646

47+
- id: minos-discovery-minos-check
48+
pass_filenames: false
49+
entry: make --directory=packages/plugins/minos-discovery-minos check
50+
name: Check minos-discovery-minos
51+
files: ^packages/plugins/minos-discovery-minos/
52+
language: system
53+
4754
- id: minos-http-aiohttp-check
4855
pass_filenames: false
4956
entry: make --directory=packages/plugins/minos-http-aiohttp check
5057
name: Check minos-http-aiohttp
5158
files: ^packages/plugins/minos-http-aiohttp/
5259
language: system
5360

54-
- id: minos-discovery-minos-check
61+
- id: minos-router-graphql-check
5562
pass_filenames: false
56-
entry: make --directory=packages/plugins/minos-discovery-minos check
57-
name: Check minos-discovery-minos
58-
files: ^packages/plugins/minos-discovery-minos/
63+
entry: make --directory=packages/plugins/minos-router-graphql check
64+
name: Check minos-router-graphql
65+
files: ^packages/plugins/minos-router-graphql/
5966
language: system

.sonarcloud.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
sonar.python.version=3.9
22
sonar.exclusions=tutorials/**
3+
sonar.cpd.exclusions=**/tests/**

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1157,6 +1157,7 @@ The plugin packages provide connectors to external technologies like brokers, di
11571157
* [minos-broker-kafka](https://minos-framework.github.io/minos-python/packages/plugins/minos-broker-kafka): The `kafka` plugin package.
11581158
* [minos-discovery-minos](https://minos-framework.github.io/minos-python/packages/plugins/minos-discovery-minos): The `minos-discovery` plugin package.
11591159
* [minos-http-aiohttp](https://minos-framework.github.io/minos-python/packages/plugins/minos-http-aiohttp): The `aiohttp` plugin package.
1160+
* [minos-router-graphql](https://minos-framework.github.io/minos-python/packages/plugins/minos-router-graphql): The `grapqhl` plugin package.
11601161
11611162
## Source Code
11621163

packages/core/minos-microservice-aggregate/minos/aggregate/aggregate.py

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,9 @@
88
get_args,
99
)
1010

11-
from dependency_injector.wiring import (
12-
Provide,
13-
inject,
14-
)
15-
1611
from minos.common import (
1712
Config,
13+
Inject,
1814
NotProvidedException,
1915
SetupMixin,
2016
)
@@ -66,31 +62,25 @@ def _from_config(cls, config: Config, **kwargs) -> Aggregate:
6662

6763
# noinspection PyUnusedLocal
6864
@staticmethod
69-
@inject
70-
def _get_transaction_repository(
71-
transaction_repository: TransactionRepository = Provide["transaction_repository"], **kwargs
72-
) -> TransactionRepository:
73-
if transaction_repository is None or isinstance(transaction_repository, Provide):
65+
@Inject()
66+
def _get_transaction_repository(transaction_repository: TransactionRepository, **kwargs) -> TransactionRepository:
67+
if transaction_repository is None:
7468
raise NotProvidedException(f"A {TransactionRepository!r} object must be provided.")
7569
return transaction_repository
7670

7771
# noinspection PyUnusedLocal
7872
@staticmethod
79-
@inject
80-
def _get_event_repository(
81-
event_repository: EventRepository = Provide["event_repository"], **kwargs
82-
) -> EventRepository:
83-
if event_repository is None or isinstance(event_repository, Provide):
73+
@Inject()
74+
def _get_event_repository(event_repository: EventRepository, **kwargs) -> EventRepository:
75+
if event_repository is None:
8476
raise NotProvidedException(f"A {EventRepository!r} object must be provided.")
8577
return event_repository
8678

8779
# noinspection PyUnusedLocal
8880
@staticmethod
89-
@inject
90-
def _get_snapshot_repository(
91-
snapshot_repository: SnapshotRepository = Provide["snapshot_repository"], **kwargs
92-
) -> SnapshotRepository:
93-
if snapshot_repository is None or isinstance(snapshot_repository, Provide):
81+
@Inject()
82+
def _get_snapshot_repository(snapshot_repository: SnapshotRepository, **kwargs) -> SnapshotRepository:
83+
if snapshot_repository is None:
9484
raise NotProvidedException(f"A {SnapshotRepository!r} object must be provided.")
9585
return snapshot_repository
9686

packages/core/minos-microservice-aggregate/minos/aggregate/entities/models.py

Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,11 @@
1717
uuid4,
1818
)
1919

20-
from dependency_injector.wiring import (
21-
Provide,
22-
inject,
23-
)
24-
2520
from minos.common import (
2621
NULL_DATETIME,
2722
NULL_UUID,
2823
DeclarativeModel,
24+
Inject,
2925
NotProvidedException,
3026
)
3127

@@ -69,61 +65,65 @@ def __init__(self, uuid: UUID, *args, **kwargs):
6965
super().__init__(uuid=uuid, *args, **kwargs)
7066

7167

68+
T = TypeVar("T", bound="RootEntity")
69+
70+
7271
class RootEntity(Entity):
7372
"""Base Root Entity class."""
7473

7574
version: int
7675
created_at: datetime
7776
updated_at: datetime
7877

79-
@inject
78+
_event_repository: EventRepository
79+
_snapshot_repository: SnapshotRepository
80+
81+
@Inject()
8082
def __init__(
8183
self,
8284
*args,
8385
uuid: UUID = NULL_UUID,
8486
version: int = 0,
8587
created_at: datetime = NULL_DATETIME,
8688
updated_at: datetime = NULL_DATETIME,
87-
_event_repository: EventRepository = Provide["event_repository"],
88-
_snapshot_repository: SnapshotRepository = Provide["snapshot_repository"],
89+
_event_repository: EventRepository,
90+
_snapshot_repository: SnapshotRepository,
8991
**kwargs,
9092
):
9193

9294
super().__init__(version, created_at, updated_at, *args, uuid=uuid, **kwargs)
9395

94-
if _event_repository is None or isinstance(_event_repository, Provide):
96+
if _event_repository is None:
9597
raise NotProvidedException(f"A {EventRepository!r} instance is required.")
96-
if _snapshot_repository is None or isinstance(_snapshot_repository, Provide):
98+
if _snapshot_repository is None:
9799
raise NotProvidedException(f"A {SnapshotRepository!r} instance is required.")
98100

99101
self._event_repository = _event_repository
100102
self._snapshot_repository = _snapshot_repository
101103

102104
@classmethod
103-
@inject
104-
async def get(
105-
cls: Type[T], uuid: UUID, *, _snapshot_repository: SnapshotRepository = Provide["snapshot_repository"], **kwargs
106-
) -> T:
105+
@Inject()
106+
async def get(cls: Type[T], uuid: UUID, *, _snapshot_repository: SnapshotRepository, **kwargs) -> T:
107107
"""Get one instance from the database based on its identifier.
108108
109109
:param uuid: The identifier of the instance.
110110
:param _snapshot_repository: Snapshot to be set to the root entity.
111111
:return: A ``RootEntity`` instance.
112112
"""
113-
if _snapshot_repository is None or isinstance(_snapshot_repository, Provide):
113+
if _snapshot_repository is None:
114114
raise NotProvidedException(f"A {SnapshotRepository!r} instance is required.")
115115

116116
# noinspection PyTypeChecker
117117
return await _snapshot_repository.get(cls.classname, uuid, _snapshot_repository=_snapshot_repository, **kwargs)
118118

119119
@classmethod
120-
@inject
120+
@Inject()
121121
def get_all(
122122
cls: Type[T],
123123
ordering: Optional[_Ordering] = None,
124124
limit: Optional[int] = None,
125125
*,
126-
_snapshot_repository: SnapshotRepository = Provide["snapshot_repository"],
126+
_snapshot_repository: SnapshotRepository,
127127
**kwargs,
128128
) -> AsyncIterator[T]:
129129
"""Get all instance from the database.
@@ -135,7 +135,7 @@ def get_all(
135135
:param _snapshot_repository: Snapshot to be set to the root entity.
136136
:return: A ``RootEntity`` instance.
137137
"""
138-
if _snapshot_repository is None or isinstance(_snapshot_repository, Provide):
138+
if _snapshot_repository is None:
139139
raise NotProvidedException(f"A {SnapshotRepository!r} instance is required.")
140140

141141
# noinspection PyTypeChecker
@@ -144,14 +144,14 @@ def get_all(
144144
)
145145

146146
@classmethod
147-
@inject
147+
@Inject()
148148
def find(
149149
cls: Type[T],
150150
condition: _Condition,
151151
ordering: Optional[_Ordering] = None,
152152
limit: Optional[int] = None,
153153
*,
154-
_snapshot_repository: SnapshotRepository = Provide["snapshot_repository"],
154+
_snapshot_repository: SnapshotRepository,
155155
**kwargs,
156156
) -> AsyncIterator[T]:
157157
"""Find a collection of instances based on a given ``Condition``.
@@ -164,7 +164,7 @@ def find(
164164
:param _snapshot_repository: Snapshot to be set to the instances.
165165
:return: An asynchronous iterator of ``RootEntity`` instances.
166166
"""
167-
if _snapshot_repository is None or isinstance(_snapshot_repository, Provide):
167+
if _snapshot_repository is None:
168168
raise NotProvidedException(f"A {SnapshotRepository!r} instance is required.")
169169
# noinspection PyTypeChecker
170170
return _snapshot_repository.find(
@@ -352,6 +352,3 @@ def from_diff(cls: Type[T], event: Event, *args, **kwargs) -> T:
352352
**event.get_fields(),
353353
**kwargs,
354354
)
355-
356-
357-
T = TypeVar("T", bound=RootEntity)

packages/core/minos-microservice-aggregate/minos/aggregate/entities/refs/resolvers.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,8 @@
1616
UUID,
1717
)
1818

19-
from dependency_injector.wiring import (
20-
Provide,
21-
inject,
22-
)
23-
2419
from minos.common import (
20+
Inject,
2521
Model,
2622
)
2723
from minos.networks import (
@@ -48,8 +44,8 @@ class RefResolver:
4844
"""Ref Resolver class."""
4945

5046
# noinspection PyUnusedLocal
51-
@inject
52-
def __init__(self, broker_pool: BrokerClientPool = Provide["broker_pool"], **kwargs):
47+
@Inject()
48+
def __init__(self, broker_pool: BrokerClientPool, **kwargs):
5349
self.broker_pool = broker_pool
5450

5551
# noinspection PyUnusedLocal

0 commit comments

Comments
 (0)