nucliadb-utils 6.3.5.post3972__py3-none-any.whl → 6.3.5.post3985__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- nucliadb_utils/audit/stream.py +2 -3
- nucliadb_utils/cache/nats.py +1 -1
- nucliadb_utils/nats.py +17 -12
- nucliadb_utils/transaction.py +6 -11
- {nucliadb_utils-6.3.5.post3972.dist-info → nucliadb_utils-6.3.5.post3985.dist-info}/METADATA +3 -3
- {nucliadb_utils-6.3.5.post3972.dist-info → nucliadb_utils-6.3.5.post3985.dist-info}/RECORD +8 -8
- {nucliadb_utils-6.3.5.post3972.dist-info → nucliadb_utils-6.3.5.post3985.dist-info}/WHEEL +0 -0
- {nucliadb_utils-6.3.5.post3972.dist-info → nucliadb_utils-6.3.5.post3985.dist-info}/top_level.txt +0 -0
nucliadb_utils/audit/stream.py
CHANGED
@@ -50,9 +50,9 @@ from nucliadb_protos.kb_usage_pb2 import (
|
|
50
50
|
)
|
51
51
|
from nucliadb_protos.nodereader_pb2 import SearchRequest
|
52
52
|
from nucliadb_protos.resources_pb2 import FieldID
|
53
|
-
from nucliadb_telemetry.jetstream import get_traced_jetstream, get_traced_nats_client
|
54
53
|
from nucliadb_utils import logger
|
55
54
|
from nucliadb_utils.audit.audit import AuditStorage
|
55
|
+
from nucliadb_utils.nats import get_traced_jetstream
|
56
56
|
from nucliadb_utils.nuclia_usage.utils.kb_usage_report import KbUsageReportUtility
|
57
57
|
|
58
58
|
|
@@ -182,8 +182,7 @@ class StreamAuditStorage(AuditStorage):
|
|
182
182
|
if len(self.nats_servers) > 0:
|
183
183
|
options["servers"] = self.nats_servers
|
184
184
|
|
185
|
-
nc = await nats.connect(**options)
|
186
|
-
self.nc = get_traced_nats_client(nc, self.service)
|
185
|
+
self.nc = await nats.connect(**options)
|
187
186
|
|
188
187
|
self.js = get_traced_jetstream(self.nc, self.service)
|
189
188
|
self.task = asyncio.create_task(self.run())
|
nucliadb_utils/cache/nats.py
CHANGED
@@ -34,9 +34,9 @@ from nats.aio.subscription import Subscription
|
|
34
34
|
from nats.js.client import JetStreamContext
|
35
35
|
from nats.js.manager import JetStreamManager
|
36
36
|
|
37
|
-
from nucliadb_telemetry.jetstream import get_traced_jetstream
|
38
37
|
from nucliadb_utils import logger
|
39
38
|
from nucliadb_utils.cache.pubsub import Callback, PubSubDriver
|
39
|
+
from nucliadb_utils.nats import get_traced_jetstream
|
40
40
|
|
41
41
|
|
42
42
|
async def wait_for_it(future: asyncio.Future, msg):
|
nucliadb_utils/nats.py
CHANGED
@@ -33,17 +33,23 @@ from nats.aio.subscription import Subscription
|
|
33
33
|
from nats.js.client import JetStreamContext
|
34
34
|
|
35
35
|
from nucliadb_telemetry.errors import capture_exception
|
36
|
-
from nucliadb_telemetry.jetstream import
|
37
|
-
|
38
|
-
NatsClientTelemetry,
|
39
|
-
get_traced_nats_client,
|
40
|
-
)
|
36
|
+
from nucliadb_telemetry.jetstream import JetStreamContextTelemetry
|
37
|
+
from nucliadb_telemetry.utils import get_telemetry
|
41
38
|
|
42
39
|
logger = logging.getLogger(__name__)
|
43
40
|
|
44
|
-
|
45
|
-
|
46
|
-
|
41
|
+
|
42
|
+
def get_traced_jetstream(
|
43
|
+
nc: NATSClient, service_name: str
|
44
|
+
) -> Union[JetStreamContext, JetStreamContextTelemetry]:
|
45
|
+
jetstream = nc.jetstream()
|
46
|
+
tracer_provider = get_telemetry(service_name)
|
47
|
+
|
48
|
+
if tracer_provider is not None and jetstream is not None: # pragma: no cover
|
49
|
+
logger.info(f"Configuring {service_name} jetstream with telemetry")
|
50
|
+
return JetStreamContextTelemetry(jetstream, service_name, tracer_provider)
|
51
|
+
else:
|
52
|
+
return jetstream
|
47
53
|
|
48
54
|
|
49
55
|
class MessageProgressUpdater:
|
@@ -98,7 +104,7 @@ class MessageProgressUpdater:
|
|
98
104
|
|
99
105
|
|
100
106
|
class NatsConnectionManager:
|
101
|
-
_nc:
|
107
|
+
_nc: NATSClient
|
102
108
|
_subscriptions: list[tuple[Subscription, Callable[[], Awaitable[None]]]]
|
103
109
|
_pull_subscriptions: list[
|
104
110
|
tuple[
|
@@ -160,8 +166,7 @@ class NatsConnectionManager:
|
|
160
166
|
options["servers"] = self._nats_servers
|
161
167
|
|
162
168
|
async with self._lock:
|
163
|
-
|
164
|
-
self._nc = get_traced_nats_client(nc, service_name=self._service_name)
|
169
|
+
self._nc = await nats.connect(**options)
|
165
170
|
|
166
171
|
self._expected_subscription_task = asyncio.create_task(self._verify_expected_subscriptions())
|
167
172
|
|
@@ -302,7 +307,7 @@ class NatsConnectionManager:
|
|
302
307
|
logger.info("Connection is closed on NATS")
|
303
308
|
|
304
309
|
@property
|
305
|
-
def nc(self) ->
|
310
|
+
def nc(self) -> NATSClient:
|
306
311
|
return self._nc
|
307
312
|
|
308
313
|
@cached_property
|
nucliadb_utils/transaction.py
CHANGED
@@ -35,14 +35,10 @@ from nucliadb_protos.writer_pb2 import (
|
|
35
35
|
Notification,
|
36
36
|
OpStatusWriter,
|
37
37
|
)
|
38
|
-
from nucliadb_telemetry.jetstream import
|
39
|
-
JetStreamContextTelemetry,
|
40
|
-
NatsClientTelemetry,
|
41
|
-
get_traced_jetstream,
|
42
|
-
get_traced_nats_client,
|
43
|
-
)
|
38
|
+
from nucliadb_telemetry.jetstream import JetStreamContextTelemetry
|
44
39
|
from nucliadb_utils import const, logger
|
45
40
|
from nucliadb_utils.cache.pubsub import PubSubDriver
|
41
|
+
from nucliadb_utils.nats import get_traced_jetstream
|
46
42
|
from nucliadb_utils.utilities import get_pubsub
|
47
43
|
|
48
44
|
|
@@ -99,7 +95,7 @@ class LocalTransactionUtility:
|
|
99
95
|
|
100
96
|
|
101
97
|
class TransactionUtility:
|
102
|
-
nc:
|
98
|
+
nc: Client
|
103
99
|
js: Union[JetStreamContext, JetStreamContextTelemetry]
|
104
100
|
pubsub: PubSubDriver
|
105
101
|
|
@@ -166,7 +162,7 @@ class TransactionUtility:
|
|
166
162
|
)
|
167
163
|
return waiting_event
|
168
164
|
|
169
|
-
async def initialize(self, service_name: str):
|
165
|
+
async def initialize(self, service_name: Optional[str] = None):
|
170
166
|
self.pubsub = await get_pubsub() # type: ignore
|
171
167
|
|
172
168
|
options: dict[str, Any] = {
|
@@ -181,9 +177,8 @@ class TransactionUtility:
|
|
181
177
|
if len(self.nats_servers) > 0:
|
182
178
|
options["servers"] = self.nats_servers
|
183
179
|
|
184
|
-
nc = await nats.connect(**options)
|
185
|
-
self.
|
186
|
-
self.js = get_traced_jetstream(self.nc, service_name)
|
180
|
+
self.nc = await nats.connect(**options)
|
181
|
+
self.js = get_traced_jetstream(self.nc, service_name or "nucliadb")
|
187
182
|
|
188
183
|
async def finalize(self):
|
189
184
|
try:
|
{nucliadb_utils-6.3.5.post3972.dist-info → nucliadb_utils-6.3.5.post3985.dist-info}/METADATA
RENAMED
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: nucliadb_utils
|
3
|
-
Version: 6.3.5.
|
3
|
+
Version: 6.3.5.post3985
|
4
4
|
Summary: NucliaDB util library
|
5
5
|
Author-email: Nuclia <nucliadb@nuclia.com>
|
6
6
|
License: AGPL
|
@@ -27,8 +27,8 @@ Requires-Dist: nats-py[nkeys]>=2.6.0
|
|
27
27
|
Requires-Dist: PyNaCl
|
28
28
|
Requires-Dist: pyjwt>=2.4.0
|
29
29
|
Requires-Dist: mrflagly>=0.2.9
|
30
|
-
Requires-Dist: nucliadb-protos>=6.3.5.
|
31
|
-
Requires-Dist: nucliadb-telemetry>=6.3.5.
|
30
|
+
Requires-Dist: nucliadb-protos>=6.3.5.post3985
|
31
|
+
Requires-Dist: nucliadb-telemetry>=6.3.5.post3985
|
32
32
|
Provides-Extra: cache
|
33
33
|
Requires-Dist: redis>=4.3.4; extra == "cache"
|
34
34
|
Requires-Dist: orjson>=3.6.7; extra == "cache"
|
@@ -7,14 +7,14 @@ nucliadb_utils/exceptions.py,sha256=y_3wk77WLVUtdo-5FtbBsdSkCtK_DsJkdWb5BoPn3qo,
|
|
7
7
|
nucliadb_utils/featureflagging.py,sha256=YxDiXzWuiDlHtqgeTVeyakmbAdzBePzJpgJv53ELbmI,2259
|
8
8
|
nucliadb_utils/grpc.py,sha256=apu0uePnkGHCAT7GRQ9YZfRYyFj26kJ440i8jitbM3U,3314
|
9
9
|
nucliadb_utils/helpers.py,sha256=nPw8yod3hP-pxq80VF8QC36s7ygSg0dBUdfI-LatvCs,1600
|
10
|
-
nucliadb_utils/nats.py,sha256
|
10
|
+
nucliadb_utils/nats.py,sha256=-ehKk0u5ZhiJEyg67yV26YysBGEGp4TDSQKq3aydJn0,15275
|
11
11
|
nucliadb_utils/partition.py,sha256=jBgy4Hu5Iwn4gjbPPcthSykwf-qNx-GcLAIwbzPd1d0,1157
|
12
12
|
nucliadb_utils/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
13
13
|
nucliadb_utils/run.py,sha256=Es0_Bu5Yc-LWczvwL6gzWqSwC85RjDCk-0oFQAJi9g4,1827
|
14
14
|
nucliadb_utils/settings.py,sha256=RnGhEUvwv6faNqALiqDCivvzNOyyXVBflYh_37uNkow,8193
|
15
15
|
nucliadb_utils/signals.py,sha256=lo_Mk12NIX5Au--3H3WObvDOXq_OMurql2qiC2TnAao,2676
|
16
16
|
nucliadb_utils/store.py,sha256=kQ35HemE0v4_Qg6xVqNIJi8vSFAYQtwI3rDtMsNy62Y,890
|
17
|
-
nucliadb_utils/transaction.py,sha256=
|
17
|
+
nucliadb_utils/transaction.py,sha256=z_VeiTIta48rosS2SXMqx86XaavprSMRWf6s6zWIeEs,7920
|
18
18
|
nucliadb_utils/utilities.py,sha256=Vc4zLpDf-FQh9bs0ZyAfGAjzlbbMTMWf3VWt2Ao5V3k,15379
|
19
19
|
nucliadb_utils/aiopynecone/__init__.py,sha256=cp15ZcFnHvpcu_5-aK2A4uUyvuZVV_MJn4bIXMa20ks,835
|
20
20
|
nucliadb_utils/aiopynecone/client.py,sha256=MPyHnDXwhukJr7U3CJh7BpsekfSuOkyM4g5b9LLtzc8,22941
|
@@ -23,10 +23,10 @@ nucliadb_utils/aiopynecone/models.py,sha256=XkNIZx4bxdbVo9zYVn8IRp70q4DWUMWN79yb
|
|
23
23
|
nucliadb_utils/audit/__init__.py,sha256=cp15ZcFnHvpcu_5-aK2A4uUyvuZVV_MJn4bIXMa20ks,835
|
24
24
|
nucliadb_utils/audit/audit.py,sha256=VDUqcSToEoz5m7iG-4omjTlsBSEJGcp0_xl51idnU3Q,3384
|
25
25
|
nucliadb_utils/audit/basic.py,sha256=pVf1oKp7T_oTDCyt8QbSsfC_uWjF66ooF6rqY-SWSrc,4032
|
26
|
-
nucliadb_utils/audit/stream.py,sha256=
|
26
|
+
nucliadb_utils/audit/stream.py,sha256=SovPj5iTzXka2cg4NnwAZwnOYljhsT6ynhDC2OsRVPc,16035
|
27
27
|
nucliadb_utils/cache/__init__.py,sha256=itSI7dtTwFP55YMX4iK7JzdMHS5CQVUiB1XzQu4UBh8,833
|
28
28
|
nucliadb_utils/cache/exceptions.py,sha256=Zu-O_-0-yctOEgoDGI92gPzWfBMRrpiAyESA62ld6MA,975
|
29
|
-
nucliadb_utils/cache/nats.py,sha256
|
29
|
+
nucliadb_utils/cache/nats.py,sha256=-AjCfkFgKVdJUlGR0hT9JDSNkPVFg4S6w9eW-ZIcXPM,7037
|
30
30
|
nucliadb_utils/cache/pubsub.py,sha256=l8i_RwRf7OPzfmPy-gyn66xgYFs5aHidCIjEaU9VOHE,1654
|
31
31
|
nucliadb_utils/cache/settings.py,sha256=WVeHOE6Re5i4k2hUHdFKfkoL4n83v_Z6UPBK6GHYb8g,1059
|
32
32
|
nucliadb_utils/encryption/__init__.py,sha256=oav6jFOTGgmIen88sdmy-bCK-uj1tyDt2hr7lB2YKik,2690
|
@@ -57,7 +57,7 @@ nucliadb_utils/tests/gcs.py,sha256=MBMzn_UHU5SU6iILuCsB5zU4umhNcaCw_MKrxZhwvOc,4
|
|
57
57
|
nucliadb_utils/tests/local.py,sha256=cxIfPrKuqs5Ef0nbrVYQQAH2mwc4E0iD9bC2sWegS-c,1934
|
58
58
|
nucliadb_utils/tests/nats.py,sha256=RWHjwqq5esuO7OFbP24yYX1cXnpPLcWJwDUdmwCpH28,1897
|
59
59
|
nucliadb_utils/tests/s3.py,sha256=DACUh3HvgH3BchKFZ9R7RFUzsrg3v9A-cxTcXx4nmvA,3734
|
60
|
-
nucliadb_utils-6.3.5.
|
61
|
-
nucliadb_utils-6.3.5.
|
62
|
-
nucliadb_utils-6.3.5.
|
63
|
-
nucliadb_utils-6.3.5.
|
60
|
+
nucliadb_utils-6.3.5.post3985.dist-info/METADATA,sha256=PHCoEtl7WwdYbBmfkRIa09XMsIsjetg3uKLeDTr4ynY,2205
|
61
|
+
nucliadb_utils-6.3.5.post3985.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
|
62
|
+
nucliadb_utils-6.3.5.post3985.dist-info/top_level.txt,sha256=fE3vJtALTfgh7bcAWcNhcfXkNPp_eVVpbKK-2IYua3E,15
|
63
|
+
nucliadb_utils-6.3.5.post3985.dist-info/RECORD,,
|
File without changes
|
{nucliadb_utils-6.3.5.post3972.dist-info → nucliadb_utils-6.3.5.post3985.dist-info}/top_level.txt
RENAMED
File without changes
|