Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: VM cache did not support connecting through a Unix socket #35

Merged
merged 1 commit into from
Jul 7, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion src/aleph/sdk/vm/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from pydantic import AnyHttpUrl

from ..conf import settings
from ..utils import check_unix_socket_valid

CacheKey = NewType("CacheKey", str)

Expand Down Expand Up @@ -52,8 +53,22 @@ def __init__(
self,
session: Optional[aiohttp.ClientSession] = None,
connector_url: Optional[AnyHttpUrl] = None,
unix_socket: Optional[str] = None,
):
self.session = session or aiohttp.ClientSession(base_url=connector_url)
if session:
self.session = session
else:
unix_socket_path = unix_socket or settings.API_UNIX_SOCKET
if unix_socket_path:
check_unix_socket_valid(unix_socket_path)
connector = aiohttp.UnixConnector(path=unix_socket_path)
else:
connector = None

self.session = aiohttp.ClientSession(
base_url=connector_url, connector=connector
)

self.cache = {}
self.api_host = connector_url if connector_url else settings.API_HOST

Expand Down
Loading