Skip to content

Commit c52d405

Browse files
committed
fix: made on success and on skip the same for orange box pipeline.
1 parent 62d7a29 commit c52d405

1 file changed

Lines changed: 25 additions & 6 deletions

File tree

src/cherami/pipelines/orange_box.py

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -141,20 +141,21 @@ def should_run(self, context: PipelineContext) -> bool:
141141

142142

143143
class OrangeBoxWorker(Worker):
144-
def on_skip(self, message: Any, context: PipelineContext) -> None:
145-
"""Handle messages that should be skipped.
144+
def on_success(self, message: Any, context: PipelineContext) -> None:
145+
"""Handle successful orange box pipeline completions.
146146
147-
Orange box implementation will add the message to the publish queue
148-
before acknowledging the message to remove it from the incoming queue.
147+
Add upstream context to payload, publish the new message with new
148+
payload to downstream queue then acknowledge the original message.
149149
150150
Args:
151151
message: The Varys message object associated with the current
152-
sample.
152+
sample.
153153
context: the object holding information about the current upstream
154154
context.
155155
156156
Raises:
157-
Exception: If the Varys client fails to acknowledge the message.
157+
Exception: If the Varys client fails to publish or acknowledge the
158+
message.
158159
"""
159160
downstream_payload = context.payload.copy()
160161
# payload should store orange box version and onyx versions hash
@@ -170,6 +171,24 @@ def on_skip(self, message: Any, context: PipelineContext) -> None:
170171

171172
self._varys_client.acknowledge_message(message)
172173

174+
def on_skip(self, message: Any, context: PipelineContext) -> None:
175+
"""Handle messages that should be skipped.
176+
177+
The same should happen as on success - add the current context to the
178+
payload, send new message to publish queue and ack message on listening
179+
queue.
180+
181+
Args:
182+
message: The Varys message object associated with the current
183+
sample.
184+
context: the object holding information about the current upstream
185+
context.
186+
187+
Raises:
188+
Exception: If the Varys client fails to acknowledge the message.
189+
"""
190+
self.on_success(message=message, context=context)
191+
173192

174193
def build_worker(
175194
config: CheramiConfig,

0 commit comments

Comments
 (0)