forked from ECCC-MSC/msc-pygeoapi
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
229 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
broker amqps://[email protected] | ||
exchange xs_snlw001 | ||
queue_name q_${BROKER_USER}.${PROGRAM}.${CONFIG}.${HOSTNAME} | ||
topic_prefix v03.post | ||
instances 2 | ||
|
||
subtopic # | ||
|
||
strip 2 | ||
directory ${MSC_PYGEOAPI_CACHEDIR} | ||
callback msc_pygeoapi.event.EventAfterWork | ||
logLevel ${MSC_PYGEOAPI_LOGGING_LOGLEVEL} | ||
report False |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,13 @@ | ||
# ================================================================= | ||
# | ||
# Author: Tom Kralidis <[email protected]> | ||
# Louis-Philippe Rousseau-Lambert | ||
# <[email protected]> | ||
# Etienne Pelletier <[email protected]> | ||
# | ||
# Copyright (c) 2021 Tom Kralidis | ||
# Copyright (c) 2024 Louis-Philippe Rousseau-Lambert | ||
# Copyright (c) 2024 Etienne Pelletier | ||
# | ||
# Permission is hereby granted, free of charge, to any person | ||
# obtaining a copy of this software and associated documentation | ||
|
@@ -26,3 +31,63 @@ | |
# OTHER DEALINGS IN THE SOFTWARE. | ||
# | ||
# ================================================================= | ||
import logging | ||
|
||
from sarracenia.flowcb import FlowCB | ||
|
||
LOGGER = logging.getLogger(__name__) | ||
|
||
|
||
class EventBase(FlowCB): | ||
|
||
def process_messages(self, worklist) -> bool: | ||
""" | ||
Process messages from the worklist | ||
:param worklist: `sarracenia.flow.worklist` | ||
:returns: `bool` | ||
""" | ||
|
||
for msg in worklist.incoming: | ||
|
||
try: | ||
from msc_pygeoapi.handler.core import CoreHandler | ||
|
||
filepath = f"{msg['new_dir']}/{msg['new_file']}" | ||
LOGGER.debug(f'Filepath: {filepath}') | ||
handler = CoreHandler(filepath) | ||
result = handler.handle() | ||
LOGGER.debug(f'Result: {result}') | ||
except Exception as err: | ||
LOGGER.error(f'Error handling message: {err}') | ||
worklist.failed.append(msg) | ||
return False | ||
|
||
return True | ||
|
||
|
||
class EventAfterWork(EventBase): | ||
|
||
def after_work(self, worklist) -> None: | ||
""" | ||
sarracenia after_work dispatcher | ||
:param worklist: `sarracenia.flow.worklist` | ||
:returns: `bool` | ||
""" | ||
return self.process_messages(worklist) | ||
|
||
|
||
class EventAfterAccept(EventBase): | ||
|
||
def after_accept(self, worklist) -> None: | ||
""" | ||
sarracenia after_accept dispatcher | ||
:param worklist: `sarracenia.flow.worklist` | ||
:returns: `bool` | ||
""" | ||
return self.process_messages(worklist) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.