Skip to content
Open
Changes from 3 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
24 changes: 20 additions & 4 deletions unstructured_ingest/processes/connectors/couchbase.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import hashlib
import signal
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused signal import accidentally committed

The signal module is imported but never used anywhere in the file. This appears to be leftover debugging or testing code that was accidentally included in the commit.

Fix in Cursor Fix in Web

import time
from contextlib import contextmanager
from dataclasses import dataclass, field
Expand Down Expand Up @@ -74,6 +75,14 @@ class CouchbaseConnectionConfig(ConnectionConfig):
collection: str = Field(
default="_default", description="The collection to connect to on the Couchbase server"
)
connect_timeout_seconds: int = Field(
default=10,
description="Timeout in seconds for establishing initial connection to Couchbase cluster"
)
bootstrap_timeout_seconds: int = Field(
default=10,
description="Timeout in seconds for bootstrapping connection to Couchbase cluster"
)
connector_type: str = Field(default=CONNECTOR_TYPE, init=False)
access_config: Secret[CouchbaseAccessConfig]

Expand All @@ -82,15 +91,22 @@ class CouchbaseConnectionConfig(ConnectionConfig):
def get_client(self) -> Generator["Cluster", None, None]:
from couchbase.auth import PasswordAuthenticator
from couchbase.cluster import Cluster
from couchbase.options import ClusterOptions
from couchbase.options import ClusterOptions, ClusterTimeoutOptions

auth = PasswordAuthenticator(self.username, self.access_config.get_secret_value().password)
options = ClusterOptions(auth)

# Configure connection timeouts
timeout_opts = ClusterTimeoutOptions(
connect_timeout=timedelta(seconds=self.connect_timeout_seconds),
bootstrap_timeout=timedelta(seconds=self.bootstrap_timeout_seconds)
)
options = ClusterOptions(auth, timeout_options=timeout_opts)
options.apply_profile("wan_development")

cluster = None
try:
cluster = Cluster(self.connection_string, options)
cluster.wait_until_ready(timedelta(seconds=5))
# Use Cluster.connect() method (not constructor) for timeouts to work
cluster = Cluster.connect(self.connection_string, options)
yield cluster
finally:
if cluster:
Expand Down
Loading