Skip to content

Commit 669e516

Browse files
Add support for unix domain sockets to WhiteListRoundRobinPolicy
1 parent 66eb290 commit 669e516

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

cassandra/policies.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import socket
2020
import warnings
2121
from cassandra import WriteType as WT
22+
from cassandra.connection import UnixSocketEndPoint
2223

2324

2425
# This is done this way because WriteType was originally
@@ -422,8 +423,13 @@ def __init__(self, hosts):
422423
connections to.
423424
"""
424425
self._allowed_hosts = tuple(hosts)
425-
self._allowed_hosts_resolved = [endpoint[4][0] for a in self._allowed_hosts
426-
for endpoint in socket.getaddrinfo(a, None, socket.AF_UNSPEC, socket.SOCK_STREAM)]
426+
self._allowed_hosts_resolved = []
427+
for h in self._allowed_hosts:
428+
if isinstance(h, UnixSocketEndPoint):
429+
self._allowed_hosts_resolved.append(h._unix_socket_path)
430+
else:
431+
self._allowed_hosts_resolved.extend([endpoint[4][0]
432+
for endpoint in socket.getaddrinfo(h, None, socket.AF_UNSPEC, socket.SOCK_STREAM)])
427433

428434
RoundRobinPolicy.__init__(self)
429435

0 commit comments

Comments
 (0)