Skip to content

Commit

Permalink
Merge pull request #495 from airbnb/ryandeivert-output-class-breakout
Browse files Browse the repository at this point in the history
[lambda][alert] breaking out output classes across files
  • Loading branch information
ryandeivert authored Nov 21, 2017
2 parents 1f5cb69 + bb51b64 commit cddd3bf
Show file tree
Hide file tree
Showing 24 changed files with 3,066 additions and 3,129 deletions.
2 changes: 1 addition & 1 deletion docs/source/outputs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ Adding support for a new service involves five steps:

- This should be a string value that corresponds to an identifier that best represents this service. (ie: ``__service__ = 'aws-s3'``)

4. Add the ``@output`` class decorator to the new subclass so it registered when the `outputs` module is loaded.
4. Add the ``@StreamAlertOutput`` class decorator to the new subclass so it registered when the `outputs` module is loaded.

5. To allow the cli to configure a new integration for this service, add the value used above for the ``__service__`` property to the ``manage.py`` file.

Expand Down
12 changes: 6 additions & 6 deletions stream_alert/alert_processor/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

from stream_alert.alert_processor import LOGGER
from stream_alert.alert_processor.helpers import validate_alert
from stream_alert.alert_processor.outputs import get_output_dispatcher
from stream_alert.alert_processor.outputs.output_base import StreamAlertOutput
from stream_alert.shared import NORMALIZATION_KEY


Expand Down Expand Up @@ -101,18 +101,18 @@ def run(alert, region, function_name, config):
continue

# Retrieve the proper class to handle dispatching the alerts of this services
output_dispatcher = get_output_dispatcher(service, region, function_name, config)
dispatcher = StreamAlertOutput.create_dispatcher(service, region, function_name, config)

if not output_dispatcher:
if not dispatcher:
continue

LOGGER.debug('Sending alert to %s:%s', service, descriptor)

sent = False
try:
sent = output_dispatcher.dispatch(descriptor=descriptor,
rule_name=alert['rule_name'],
alert=alert)
sent = dispatcher.dispatch(descriptor=descriptor,
rule_name=alert['rule_name'],
alert=alert)

except Exception as err: # pylint: disable=broad-except
LOGGER.exception('An error occurred while sending alert '
Expand Down
Loading

0 comments on commit cddd3bf

Please sign in to comment.