Skip to content

Commit

Permalink
Address review comments, remove redis support
Browse files Browse the repository at this point in the history
  • Loading branch information
sciyoshi committed Jun 4, 2024
1 parent 42aba73 commit ecf2fa5
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 37 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
[![PyPI](https://img.shields.io/pypi/v/asyncio-connection-pool?style=flat)][package]
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/asyncio-connection-pool?style=flat)][package]
[![codecov](https://codecov.io/gh/fellowapp/asyncio-connection-pool/graph/badge.svg?token=F3D4D9EG6M)](https://codecov.io/gh/fellowapp/asyncio-connection-pool)
[![License](https://img.shields.io/pypi/l/prosemirror.svg?style=flat)](https://github.com/fellowapp/asyncio-connection-pool/blob/master/LICENSE.md)
[![Fellow Careers](https://img.shields.io/badge/fellow.app-hiring-576cf7.svg?style=flat)](https://fellow.app/careers/)

[main CI]: https://github.com/fellowapp/asyncio-connection-pool/actions?query=workflow%3ACI+branch%3Amain
Expand Down
22 changes: 0 additions & 22 deletions asyncio_connection_pool/contrib/aioredis.py

This file was deleted.

32 changes: 19 additions & 13 deletions asyncio_connection_pool/contrib/datadog.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from contextlib import AsyncExitStack, asynccontextmanager
from typing import AsyncIterator, Awaitable, TypeVar
from typing import Any, AsyncIterator, Awaitable, Coroutine, TypeVar

from datadog.dogstatsd.base import statsd
from ddtrace import tracer
Expand Down Expand Up @@ -85,29 +85,35 @@ def _record_connection_acquiring(self, value: int = 0) -> None:
tags=self._extra_tags,
)

async def _connection_maker(self) -> Conn:
def _connection_maker(self) -> Coroutine[Any, Any, Conn]:
statsd.increment(
f"{self._service_name}.pool.getting_connection",
tags=[*self._extra_tags, "method:new"],
)

with tracer.trace(
f"{self._service_name}.pool._create_new_connection",
service=self._service_name,
):
return await super()._connection_maker()
async def connection_maker(self) -> Conn:
with tracer.trace(
f"{self._service_name}.pool._create_new_connection",
service=self._service_name,
):
return await super()._connection_maker()

return connection_maker(self)

async def _connection_waiter(self) -> Conn:
def _connection_waiter(self) -> Coroutine[Any, Any, Conn]:
statsd.increment(
f"{self._service_name}.pool.getting_connection",
tags=[*self._extra_tags, "method:wait"],
)

with tracer.trace(
f"{self._service_name}.pool._wait_for_connection",
service=self._service_name,
):
return await super()._connection_waiter()
async def connection_waiter(self) -> Conn:
with tracer.trace(
f"{self._service_name}.pool._wait_for_connection",
service=self._service_name,
):
return await super()._connection_waiter()

return connection_waiter(self)

def _get_conn(self) -> Awaitable[Conn]:
if not self.available.empty():
Expand Down
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ dependencies = []

[project.optional-dependencies]
datadog = ["ddtrace", "datadog"]
aioredis = ["redis>=4.2"]
dev = [
"codecov~=2.1",
"mypy~=1.9",
Expand Down
2 changes: 1 addition & 1 deletion test/test_pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ async def worker():
assert pool.in_use == nworkers, "all workers should have their connections now"
ev2.set()
await asyncio.gather(*coros)
assert pool.currently_allocating == 0
assert pool.in_use == 0
assert (
pool.available.qsize() == nworkers
), "all workers should have returned their connections"
Expand Down

0 comments on commit ecf2fa5

Please sign in to comment.