mirror of
https://github.com/langgenius/dify.git
synced 2026-03-10 01:46:14 +08:00
feat(trigger): implement debug session capabilities for trigger nodes
- Added `DraftWorkflowTriggerNodeApi` to handle debugging of trigger nodes, allowing for real-time event listening and session management. - Introduced `TriggerDebugService` for managing debug sessions and event dispatching using Redis Pub/Sub. - Updated `TriggerService` to support dispatching events to debug sessions and refactored related methods for improved clarity and functionality. - Enhanced data structures in `request.py` and `entities.py` to accommodate new debug event data requirements. These changes significantly improve the debugging capabilities for trigger nodes in draft workflows, facilitating better development and troubleshooting processes.
This commit is contained in:
@ -88,12 +88,11 @@ def dispatch_triggered_workflows_async(
|
||||
)
|
||||
continue
|
||||
|
||||
TriggerService.process_triggered_workflows(
|
||||
dispatched_count += TriggerService.dispatch_triggered_workflows(
|
||||
subscription=subscription,
|
||||
trigger=trigger,
|
||||
request=request,
|
||||
request_id=request_id,
|
||||
)
|
||||
dispatched_count += 1
|
||||
|
||||
except Exception:
|
||||
logger.exception(
|
||||
@ -104,6 +103,18 @@ def dispatch_triggered_workflows_async(
|
||||
# Continue processing other triggers even if one fails
|
||||
continue
|
||||
|
||||
# Dispatch to debug sessions after processing all triggers
|
||||
try:
|
||||
debug_dispatched = TriggerService.dispatch_debugging_sessions(
|
||||
subscription_id=subscription_id,
|
||||
request=request,
|
||||
triggers=triggers,
|
||||
request_id=request_id,
|
||||
)
|
||||
except Exception:
|
||||
# Silent failure for debug dispatch
|
||||
logger.exception("Failed to dispatch to debug sessions")
|
||||
|
||||
logger.info(
|
||||
"Completed async trigger dispatching: processed %d/%d triggers",
|
||||
dispatched_count,
|
||||
@ -117,8 +128,9 @@ def dispatch_triggered_workflows_async(
|
||||
|
||||
return {
|
||||
"status": "completed",
|
||||
"dispatched_count": dispatched_count,
|
||||
"total_count": len(triggers),
|
||||
"dispatched_count": dispatched_count,
|
||||
"debug_dispatched_count": debug_dispatched,
|
||||
}
|
||||
|
||||
except Exception as e:
|
||||
|
||||
Reference in New Issue
Block a user