Skip to content

Commit

Permalink
Adds canary support for signals. (#3785)
Browse files Browse the repository at this point in the history
* clean pr

* Add revision
  • Loading branch information
kevgliss authored Sep 13, 2023
1 parent 14f2a56 commit 323ddb7
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
"""Adds canary column to signal_instance
Revision ID: e875e9544048
Revises: 0560fab4537f
Create Date: 2023-09-13 09:31:24.223488
"""
from alembic import op
import sqlalchemy as sa

# revision identifiers, used by Alembic.
revision = "e875e9544048"
down_revision = "0560fab4537f"
branch_labels = None
depends_on = None


def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column("signal_instance", sa.Column("canary", sa.Boolean(), nullable=True))
# ### end Alembic commands ###


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_column("signal_instance", "canary")
4 changes: 4 additions & 0 deletions src/dispatch/signal/flows.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ def signal_instance_create_flow(
)
return signal_instance

# limited support for canary signals, just store the instance and return
if signal_instance.canary:
return signal_instance

if not signal_instance.signal.create_case:
return signal_instance

Expand Down
2 changes: 2 additions & 0 deletions src/dispatch/signal/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ class SignalInstance(Base, TimeStampMixin, ProjectMixin):
case_priority = relationship("CasePriority", backref="signal_instances")
fingerprint = Column(String)
filter_action = Column(String)
canary = Column(Boolean, default=False)
raw = Column(JSONB)
signal = relationship("Signal", backref="instances")
signal_id = Column(Integer, ForeignKey("signal.id"))
Expand Down Expand Up @@ -364,6 +365,7 @@ class AdditionalMetadata(DispatchBase):
class SignalInstanceBase(DispatchBase):
project: ProjectRead
case: Optional[CaseReadMinimal]
canary: Optional[bool] = False
entities: Optional[List[EntityRead]] = []
raw: dict[str, Any]
filter_action: SignalFilterAction = None
Expand Down

0 comments on commit 323ddb7

Please sign in to comment.