Skip to content

Commit 54424f2

Browse files
committed
update caching logic, add dep
1 parent a21d9c0 commit 54424f2

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

msc-wis2node-management/msc_wis2node/publisher.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -183,13 +183,6 @@ def publish_to_wis2(self, dataset: dict, url: str) -> None:
183183
url=url
184184
)
185185

186-
if self.cache is not None:
187-
LOGGER.debug('Checking for data update')
188-
if self.cache.get(message['properties']['data_id']) is not None:
189-
update_link = deepcopy(message['links'][0])
190-
update_link['rel'] = 'update'
191-
message['links'].append(update_link)
192-
193186
cache = dataset.get('cache', True)
194187
if not cache:
195188
LOGGER.info(f'Setting properties.cache={cache}')
@@ -200,6 +193,13 @@ def publish_to_wis2(self, dataset: dict, url: str) -> None:
200193
tokens = data_id.split('/')
201194
message['properties']['data_id'] = '/'.join(tokens[2:])
202195

196+
if self.cache is not None:
197+
LOGGER.info(f"Checking for duplicate: {message['properties']['data_id']}") # noqa
198+
if self.cache.get(message['properties']['data_id']) is not None:
199+
update_link = deepcopy(message['links'][0])
200+
update_link['rel'] = 'update'
201+
message['links'].append(update_link)
202+
203203
LOGGER.info(json.dumps(message, indent=4))
204204
msg = (f'Publishing WIS2 notification message to '
205205
f'host={BROKER_HOSTNAME}, port={BROKER_PORT}, topic={topic}')
@@ -220,7 +220,7 @@ def publish_to_wis2(self, dataset: dict, url: str) -> None:
220220
)
221221

222222
if self.cache is not None:
223-
LOGGER.debug('Setting cache key')
223+
LOGGER.info(f"Setting cache key for {message['properties']['data_id']}") # noqa
224224
self.cache.set(message['properties']['data_id'], 'published',
225225
ex=CACHE_EXPIRY_SECONDS)
226226

msc-wis2node-management/requirements.txt

+1
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@ amqp
22
certifi
33
click
44
metpx-sr3
5+
paramiko
56
pywis-pubsub
67
redis[hiredis]

0 commit comments

Comments
 (0)