Skip to content

Commit

Permalink
Merge pull request #150 from vkottler/dev/3.0.0
Browse files Browse the repository at this point in the history
3.0.0 - Add connection name to factory client call
  • Loading branch information
vkottler authored Nov 7, 2023
2 parents 85e7c69 + a97e1b9 commit 4f36961
Show file tree
Hide file tree
Showing 11 changed files with 20 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ jobs:
- run: |
mk python-release owner=vkottler \
repo=runtimepy version=2.14.3
repo=runtimepy version=3.0.0
if: |
matrix.python-version == '3.11'
&& matrix.system == 'ubuntu-latest'
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
=====================================
generator=datazen
version=3.1.4
hash=0eec08fe9632a2521fd0073da5b804b9
hash=610bd14e939eb969ca263a9120a3bf74
=====================================
-->

# runtimepy ([2.14.3](https://pypi.org/project/runtimepy/))
# runtimepy ([3.0.0](https://pypi.org/project/runtimepy/))

[![python](https://img.shields.io/pypi/pyversions/runtimepy.svg)](https://pypi.org/project/runtimepy/)
![Build Status](https://github.com/vkottler/runtimepy/workflows/Python%20Package/badge.svg)
Expand Down
2 changes: 1 addition & 1 deletion config
6 changes: 3 additions & 3 deletions local/variables/package.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
major: 2
minor: 14
patch: 3
major: 3
minor: 0
patch: 0
entry: runtimepy
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta:__legacy__"

[project]
name = "runtimepy"
version = "2.14.3"
version = "3.0.0"
description = "A framework for implementing Python services."
readme = "README.md"
requires-python = ">=3.11"
Expand Down
4 changes: 2 additions & 2 deletions runtimepy/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# =====================================
# generator=datazen
# version=3.1.4
# hash=d4f579524fe603dbd5b373ea2364b9e3
# hash=4e93b895f12cc33656430fad15c424e5
# =====================================

"""
Expand All @@ -10,7 +10,7 @@

DESCRIPTION = "A framework for implementing Python services."
PKG_NAME = "runtimepy"
VERSION = "2.14.3"
VERSION = "3.0.0"

# runtimepy-specific content.
METRICS_NAME = "metrics"
4 changes: 2 additions & 2 deletions runtimepy/net/arbiter/factory/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
class ConnectionFactory:
"""An interface for creating client connections."""

async def client(self, *args, **kwargs) -> _Connection:
async def client(self, name: str, *args, **kwargs) -> _Connection:
"""Create a client connection."""
raise NotImplementedError

Expand Down Expand Up @@ -91,7 +91,7 @@ async def factory_client(
if factory in self._conn_factories:
factory_inst = self._conn_factories[factory]

conn = factory_inst.client(*args, **kwargs)
conn = factory_inst.client(name, *args, **kwargs)
if not defer:
conn = await conn # type: ignore

Expand Down
3 changes: 2 additions & 1 deletion runtimepy/net/arbiter/tcp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@ class TcpConnectionFactory(_ConnectionFactory, _Generic[T]):

kind: _Type[T]

async def client(self, *args, **kwargs) -> _Connection:
async def client(self, name: str, *args, **kwargs) -> _Connection:
"""Create a client connection."""

del name
assert not [*args], "Only keyword arguments are used!"
return await self.kind.create_connection(**kwargs)

Expand Down
3 changes: 2 additions & 1 deletion runtimepy/net/arbiter/udp.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ class UdpConnectionFactory(

kind: _Type[T]

async def client(self, *args, **kwargs) -> _Connection:
async def client(self, name: str, *args, **kwargs) -> _Connection:
"""Create a client connection."""

del name
assert not [*args], "Only keyword arguments are used!"
return await self.kind.create_connection(**kwargs)
4 changes: 3 additions & 1 deletion runtimepy/net/arbiter/websocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@ class WebsocketConnectionFactory(_ConnectionFactory, _Generic[T]):

kind: _Type[T]

async def client(self, *args, **kwargs) -> _Connection:
async def client(self, name: str, *args, **kwargs) -> _Connection:
"""Create a client connection."""

del name
return await self.kind.create_connection(*args, **kwargs)

async def server_task(
Expand Down
2 changes: 1 addition & 1 deletion tests/net/arbiter/test_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ async def test_connection_factory_basic():
factory = ConnectionFactory()

with raises(NotImplementedError):
await factory.client()
await factory.client("test")

with raises(NotImplementedError):
await factory.server_task(None, None, None) # type: ignore

0 comments on commit 4f36961

Please sign in to comment.