Skip to content

Commit

Permalink
Enrich archive_event with more information
Browse files Browse the repository at this point in the history
We previously only passed a file's ID and version to the plug-ins
through this event. We now pass the disk ID and the server itself,
allowing plug-ins to perform much more complex operations when they
receive these events.

This small development was done as part of NGAS-164.

Signed-off-by: Rodrigo Tobar <[email protected]>
  • Loading branch information
rtobar committed Nov 22, 2023
1 parent d845e2d commit f15528c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/ngamsServer/ngamsServer/ngamsArchiveUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1253,7 +1253,7 @@ def finish_archive_request(srv, req, http_ref, plugin_result, disk_info):
http_ref.send_ingest_status(msg, disk_info)

# After a successful archiving we notify the archive event subscribers
srv.fire_archive_event(plugin_result.getFileId(), plugin_result.getFileVersion())
srv.fire_archive_event(disk_info.getDiskId(), plugin_result.getFileId(), plugin_result.getFileVersion())

def findTargetNode(stream, srvObj, mimeType):
"""
Expand Down
6 changes: 3 additions & 3 deletions src/ngamsServer/ngamsServer/ngamsServer.py
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,7 @@ def show_threads():
msg.append(fmt % (t.name, t.ident, t.daemon))
logger.debug("Threads currently alive on process %d:\n%s", os.getpid(), '\n'.join(msg))

archive_event = collections.namedtuple('archive_event', 'file_id file_version')
archive_event = collections.namedtuple('archive_event', 'disk_id file_id file_version server')

class ngamsServer(object):
"""
Expand Down Expand Up @@ -751,9 +751,9 @@ def trigger_subscription(evt):
plugin = loadPlugInEntryPoint(module, clazz)(**pars)
self.archive_event_subscribers.append(plugin.handle_event)

def fire_archive_event(self, file_id, file_version):
def fire_archive_event(self, disk_id, file_id, file_version):
"""Passes down the archive event to each of the archive event subscriber"""
evt = archive_event(file_id, file_version)
evt = archive_event(disk_id, file_id, file_version, self)
for s in self.archive_event_subscribers:
try:
s(evt)
Expand Down

0 comments on commit f15528c

Please sign in to comment.