Skip to content
This repository has been archived by the owner on Jan 28, 2022. It is now read-only.

Commit

Permalink
Merge pull request #392 from Clariteia/0.0.16
Browse files Browse the repository at this point in the history
0.0.16
  • Loading branch information
Sergio García Prado authored Sep 20, 2021
2 parents 91bf63c + d7353f2 commit 810fd13
Show file tree
Hide file tree
Showing 97 changed files with 644 additions and 785 deletions.
7 changes: 7 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,10 @@ History
------------------

* Add support for `__get_enroute__` method by `EnrouteAnalyzer`.

0.0.16 (2021-09-20)
------------------

* Add support for `Kong` discovery.
* Add support for `minos-microservice-common>=0.1.13`.
* Fix bug related with database queues and plain dates (without timezones).
7 changes: 4 additions & 3 deletions minos/networks/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
"""minos.networks module."""

__version__ = "0.0.15"
__version__ = "0.0.16"

from .brokers import (
Broker,
Expand All @@ -26,14 +24,17 @@
enroute,
)
from .discovery import (
DiscoveryClient,
DiscoveryConnector,
KongDiscoveryClient,
MinosDiscoveryClient,
)
from .exceptions import (
MinosActionNotFoundException,
MinosDiscoveryConnectorException,
MinosHandlerException,
MinosHandlerNotFoundEnoughEntriesException,
MinosInvalidDiscoveryClient,
MinosMultipleEnrouteDecoratorKindsException,
MinosNetworkException,
MinosRedefinedEnrouteDecoratorException,
Expand Down
7 changes: 0 additions & 7 deletions minos/networks/brokers/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
"""
Copyright (C) 2021 Clariteia SL
This file is part of minos framework.
Minos framework can not be copied and/or distributed without the express permission of Clariteia SL.
"""
from .abc import (
Broker,
BrokerSetup,
Expand Down
30 changes: 8 additions & 22 deletions minos/networks/brokers/abc.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,6 @@
"""
Copyright (C) 2021 Clariteia SL
This file is part of minos framework.
Minos framework can not be copied and/or distributed without the express permission of Clariteia SL.
"""
from abc import (
ABC,
)
from typing import (
NoReturn,
)

from psycopg2.sql import (
SQL,
Expand All @@ -25,10 +15,10 @@
class BrokerSetup(PostgreSqlMinosDatabase):
"""Minos Broker Setup Class"""

async def _setup(self) -> NoReturn:
async def _setup(self) -> None:
await self._create_broker_table()

async def _create_broker_table(self) -> NoReturn:
async def _create_broker_table(self) -> None:
await self.submit_query(_CREATE_TABLE_QUERY, lock=hash("producer_queue"))


Expand All @@ -44,7 +34,7 @@ async def enqueue(self, topic: str, raw: bytes) -> int:
:param raw: Bytes sequence to be send.
:return: The identifier of the message in the queue.
"""
params = (topic, raw, 0, self.ACTION)
params = (topic, raw, self.ACTION)
raw = await self.submit_query_and_fetchone(_INSERT_ENTRY_QUERY, params)
await self.submit_query(_NOTIFY_QUERY)
return raw[0]
Expand All @@ -54,17 +44,13 @@ async def enqueue(self, topic: str, raw: bytes) -> int:
"CREATE TABLE IF NOT EXISTS producer_queue ("
"id BIGSERIAL NOT NULL PRIMARY KEY, "
"topic VARCHAR(255) NOT NULL, "
"model BYTEA NOT NULL, "
"retry INTEGER NOT NULL, "
"data BYTEA NOT NULL, "
"action VARCHAR(255) NOT NULL, "
"creation_date TIMESTAMP NOT NULL, "
"update_date TIMESTAMP NOT NULL)"
"retry INTEGER NOT NULL DEFAULT 0, "
"created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(), "
"updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW())"
)

_INSERT_ENTRY_QUERY = SQL(
"INSERT INTO producer_queue (topic, model, retry, action, creation_date, update_date) "
"VALUES (%s, %s, %s, %s, NOW(), NOW()) "
"RETURNING id"
)
_INSERT_ENTRY_QUERY = SQL("INSERT INTO producer_queue (topic, data, action) VALUES (%s, %s, %s) RETURNING id")

_NOTIFY_QUERY = SQL("NOTIFY producer_queue")
7 changes: 0 additions & 7 deletions minos/networks/brokers/command_replies.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
"""
Copyright (C) 2021 Clariteia SL
This file is part of minos framework.
Minos framework can not be copied and/or distributed without the express permission of Clariteia SL.
"""
from __future__ import (
annotations,
)
Expand Down
2 changes: 0 additions & 2 deletions minos/networks/brokers/commands.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
"""minos.networks.brokers.commands module."""

from __future__ import (
annotations,
)
Expand Down
7 changes: 0 additions & 7 deletions minos/networks/brokers/events.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
"""
Copyright (C) 2021 Clariteia SL
This file is part of minos framework.
Minos framework can not be copied and/or distributed without the express permission of Clariteia SL.
"""
from __future__ import (
annotations,
)
Expand Down
8 changes: 3 additions & 5 deletions minos/networks/brokers/producers.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
"""minos.networks.brokers.producers module."""

from __future__ import (
annotations,
)
Expand Down Expand Up @@ -165,7 +163,7 @@ async def dispatch_one(self, row: tuple) -> bool:
:param row: A row containing the message information.
:return: ``True`` if everything was fine or ``False`` otherwise.
"""
topic, message, action = row[1], row[2], row[4]
topic, message, action = row[1], row[2], row[3]

# noinspection PyBroadException
try:
Expand Down Expand Up @@ -209,15 +207,15 @@ def client(self) -> AIOKafkaProducer:
"SELECT * "
"FROM producer_queue "
"WHERE retry < %s "
"ORDER BY creation_date "
"ORDER BY created_at "
"LIMIT %s "
"FOR UPDATE "
"SKIP LOCKED"
)

_DELETE_PROCESSED_QUERY = SQL("DELETE FROM producer_queue WHERE id = %s")

_UPDATE_NOT_PROCESSED_QUERY = SQL("UPDATE producer_queue SET retry = retry + 1 WHERE id = %s")
_UPDATE_NOT_PROCESSED_QUERY = SQL("UPDATE producer_queue SET retry = retry + 1, updated_at = NOW() WHERE id = %s")

_LISTEN_QUERY = SQL("LISTEN producer_queue")

Expand Down
2 changes: 0 additions & 2 deletions minos/networks/brokers/services.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
"""minos.networks.brokers.services module."""

from __future__ import (
annotations,
)
Expand Down
7 changes: 0 additions & 7 deletions minos/networks/decorators/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
"""
Copyright (C) 2021 Clariteia SL
This file is part of minos framework.
Minos framework can not be copied and/or distributed without the express permission of Clariteia SL.
"""
from .analyzers import (
EnrouteAnalyzer,
)
Expand Down
7 changes: 0 additions & 7 deletions minos/networks/decorators/analyzers.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
"""
Copyright (C) 2021 Clariteia SL
This file is part of minos framework.
Minos framework can not be copied and/or distributed without the express permission of Clariteia SL.
"""
from inspect import (
getmembers,
isfunction,
Expand Down
7 changes: 0 additions & 7 deletions minos/networks/decorators/api.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
"""
Copyright (C) 2021 Clariteia SL
This file is part of minos framework.
Minos framework can not be copied and/or distributed without the express permission of Clariteia SL.
"""
from .definitions import (
BrokerCommandEnrouteDecorator,
BrokerEventEnrouteDecorator,
Expand Down
7 changes: 0 additions & 7 deletions minos/networks/decorators/builders.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
"""
Copyright (C) 2021 Clariteia SL
This file is part of minos framework.
Minos framework can not be copied and/or distributed without the express permission of Clariteia SL.
"""
from inspect import (
iscoroutinefunction,
)
Expand Down
7 changes: 0 additions & 7 deletions minos/networks/decorators/definitions/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
"""
Copyright (C) 2021 Clariteia SL
This file is part of minos framework.
Minos framework can not be copied and/or distributed without the express permission of Clariteia SL.
"""
from .abc import (
EnrouteDecorator,
)
Expand Down
9 changes: 1 addition & 8 deletions minos/networks/decorators/definitions/abc.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
# Copyright (C) 2020 Clariteia SL
#
# This file is part of minos framework.
#
# Minos framework can not be copied and/or distributed without the express
# permission of Clariteia SL.
from __future__ import (
annotations,
)
Expand All @@ -20,7 +14,6 @@
Callable,
Final,
Iterable,
NoReturn,
Optional,
Union,
)
Expand All @@ -36,7 +29,7 @@
EnrouteDecoratorKind,
)

Adapter = Callable[[Request], Union[Response, NoReturn, None, Awaitable[Union[Response, NoReturn, None]]]]
Adapter = Callable[[Request], Union[Optional[Response], Awaitable[Optional[Response]]]]


class EnrouteDecorator(ABC):
Expand Down
7 changes: 0 additions & 7 deletions minos/networks/decorators/definitions/broker.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
"""
Copyright (C) 2021 Clariteia SL
This file is part of minos framework.
Minos framework can not be copied and/or distributed without the express permission of Clariteia SL.
"""
from abc import (
ABC,
)
Expand Down
7 changes: 0 additions & 7 deletions minos/networks/decorators/definitions/kinds.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
"""
Copyright (C) 2021 Clariteia SL
This file is part of minos framework.
Minos framework can not be copied and/or distributed without the express permission of Clariteia SL.
"""
from enum import (
Enum,
auto,
Expand Down
7 changes: 0 additions & 7 deletions minos/networks/decorators/definitions/rest.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
"""
Copyright (C) 2021 Clariteia SL
This file is part of minos framework.
Minos framework can not be copied and/or distributed without the express permission of Clariteia SL.
"""
from abc import (
ABC,
)
Expand Down
9 changes: 2 additions & 7 deletions minos/networks/discovery/__init__.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
"""
Copyright (C) 2021 Clariteia SL
This file is part of minos framework.
Minos framework can not be copied and/or distributed without the express permission of Clariteia SL.
"""
from .clients import (
DiscoveryClient,
KongDiscoveryClient,
MinosDiscoveryClient,
)
from .connectors import (
Expand Down
9 changes: 9 additions & 0 deletions minos/networks/discovery/clients/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from .abc import (
DiscoveryClient,
)
from .kong import (
KongDiscoveryClient,
)
from .minos import (
MinosDiscoveryClient,
)
Loading

0 comments on commit 810fd13

Please sign in to comment.