-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rabbitmq fixes/enhancements for scheduler (#1976)
Co-authored-by: ammar92 <[email protected]> Co-authored-by: Jan Klopper <[email protected]>
- Loading branch information
1 parent
56c8004
commit e622b3f
Showing
16 changed files
with
2,253 additions
and
2,045 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
Large diffs are not rendered by default.
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
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
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
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,45 +1,9 @@ | ||
from typing import Callable | ||
|
||
from scheduler.models import RawDataReceivedEvent | ||
|
||
from .listeners import RabbitMQ | ||
|
||
|
||
class RawData(RabbitMQ): | ||
"""The RawData listener class that listens to the raw data queue and calls | ||
the function passed to it. This is used within the NormalizerScheduler. | ||
Attributes: | ||
queue: A string representing the messaging queue name. | ||
func: A python callable. | ||
prefetch_count: An integer representing the prefetch count. | ||
""" | ||
|
||
def __init__(self, dsn: str, queue: str, func: Callable, prefetch_count: int): | ||
"""Initialize the RawData listener. | ||
Args: | ||
dsn: A string representing the DSN. | ||
queue: A string representing the messaging queue name. | ||
func: A python callable. | ||
prefetch_count: An integer representing the prefetch count. | ||
""" | ||
super().__init__(dsn) | ||
self.queue = queue | ||
self.func = func | ||
self.prefetch_count = prefetch_count | ||
|
||
def listen(self) -> None: | ||
"""Listen to the messaging queue.""" | ||
self.basic_consume(self.queue, True, self.prefetch_count) | ||
|
||
def dispatch(self, body: bytes) -> None: | ||
"""Dispatch the message to the function. | ||
body: A bytes object representing the body of the message. | ||
""" | ||
# Convert body into a RawDataReceivedEvent | ||
model = RawDataReceivedEvent.parse_raw(body) | ||
|
||
# Call the function | ||
self.func(model) | ||
pass |
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,46 +1,10 @@ | ||
from typing import Callable | ||
|
||
from scheduler.models import ScanProfileMutation as ScanProfileMutationModel | ||
|
||
from .listeners import RabbitMQ | ||
|
||
|
||
class ScanProfileMutation(RabbitMQ): | ||
"""The ScanProfileMutation listener class that listens to the scan profile | ||
mutation queue and calls the function passed to it. This is used within the | ||
BoefjeScheduler. | ||
Attributes: | ||
queue: A string representing the messaging queue name. | ||
func: A python callable. | ||
prefetch_count: An integer representing the prefetch count. | ||
""" | ||
|
||
def __init__(self, dsn: str, queue: str, func: Callable, prefetch_count: int): | ||
"""Initialize the RawData listener. | ||
Args: | ||
dsn: A string representing the DSN. | ||
queue: A string representing the messaging queue name. | ||
func: A python callable. | ||
prefetch_count: An integer representing the prefetch count. | ||
""" | ||
super().__init__(dsn) | ||
self.queue = queue | ||
self.func = func | ||
self.prefetch_count = prefetch_count | ||
|
||
def listen(self) -> None: | ||
"""Listen to the messaging queue.""" | ||
self.basic_consume(self.queue, True, self.prefetch_count) | ||
|
||
def dispatch(self, body: bytes) -> None: | ||
"""Dispatch the message to the function. | ||
body: A bytes object representing the body of the message. | ||
""" | ||
# Convert body into a ScanProfileMutationModel | ||
model = ScanProfileMutationModel.parse_raw(body) | ||
|
||
# Call the function | ||
self.func(model) | ||
pass |
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
Oops, something went wrong.