Skip to content

Commit

Permalink
Add support for unix domain sockets to WhiteListRoundRobinPolicy
Browse files Browse the repository at this point in the history
  • Loading branch information
sylwiaszunejko committed Jan 12, 2024
1 parent 66eb290 commit 669e516
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions cassandra/policies.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import socket
import warnings
from cassandra import WriteType as WT
from cassandra.connection import UnixSocketEndPoint


# This is done this way because WriteType was originally
Expand Down Expand Up @@ -422,8 +423,13 @@ def __init__(self, hosts):
connections to.
"""
self._allowed_hosts = tuple(hosts)
self._allowed_hosts_resolved = [endpoint[4][0] for a in self._allowed_hosts
for endpoint in socket.getaddrinfo(a, None, socket.AF_UNSPEC, socket.SOCK_STREAM)]
self._allowed_hosts_resolved = []
for h in self._allowed_hosts:
if isinstance(h, UnixSocketEndPoint):
self._allowed_hosts_resolved.append(h._unix_socket_path)
else:
self._allowed_hosts_resolved.extend([endpoint[4][0]
for endpoint in socket.getaddrinfo(h, None, socket.AF_UNSPEC, socket.SOCK_STREAM)])

RoundRobinPolicy.__init__(self)

Expand Down

0 comments on commit 669e516

Please sign in to comment.