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

Make cqlsh work with unix domain sockets #67

Merged
merged 2 commits into from
Jan 17, 2024
Merged
Show file tree
Hide file tree
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
14 changes: 11 additions & 3 deletions bin/cqlsh.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ def find_zip(libprefix):

from cassandra.auth import PlainTextAuthProvider
from cassandra.cluster import Cluster, EXEC_PROFILE_DEFAULT, ExecutionProfile
from cassandra.connection import UnixSocketEndPoint
from cassandra.cqltypes import cql_typename
from cassandra.marshal import int64_unpack
from cassandra.metadata import (ColumnMetadata, KeyspaceMetadata, TableMetadata, protect_name, protect_names, protect_value)
Expand Down Expand Up @@ -485,10 +486,14 @@ def __init__(self, hostname, port, color=False,
}

if cloudconf is None:
kwargs['contact_points'] = (self.hostname,)
if os.path.exists(self.hostname) and stat.S_ISSOCK(os.stat(self.hostname).st_mode):
kwargs['contact_points'] = (UnixSocketEndPoint(self.hostname),)
profiles[EXEC_PROFILE_DEFAULT].load_balancing_policy = WhiteListRoundRobinPolicy([UnixSocketEndPoint(self.hostname)])
else:
kwargs['contact_points'] = (self.hostname,)
profiles[EXEC_PROFILE_DEFAULT].load_balancing_policy = WhiteListRoundRobinPolicy([self.hostname])
kwargs['port'] = self.port
kwargs['ssl_context'] = sslhandling.ssl_settings(hostname, CONFIG_FILE) if ssl else None
profiles[EXEC_PROFILE_DEFAULT].load_balancing_policy = WhiteListRoundRobinPolicy([self.hostname])
else:
assert 'scylla' in DRIVER_NAME.lower(), f"{DRIVER_NAME} {DRIVER_VERSION} isn't supported by scylla_cloud"
kwargs['scylla_cloud'] = cloudconf
Expand Down Expand Up @@ -2126,7 +2131,10 @@ def do_login(self, parsed):
kwargs['contact_points'] = (self.hostname,)
kwargs['port'] = self.port
kwargs['ssl_context'] = self.conn.ssl_context
kwargs['load_balancing_policy'] = WhiteListRoundRobinPolicy([self.hostname])
if os.path.exists(self.hostname) and stat.S_ISSOCK(os.stat(self.hostname).st_mode):
kwargs['load_balancing_policy'] = WhiteListRoundRobinPolicy([UnixSocketEndPoint(self.hostname)])
else:
kwargs['load_balancing_policy'] = WhiteListRoundRobinPolicy([self.hostname])
else:
kwargs['scylla_cloud'] = self.cloudconf

Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
scylla-driver==3.26.3
scylla-driver==3.26.5
geomet==0.2.1.post1
PyYAML==6.0
click==8.1.3
Expand Down