fix: correct building reference

This commit is contained in:
Yeuoly
2025-10-18 19:54:06 +08:00
parent 3a18337129
commit 65c6203ad7
6 changed files with 55 additions and 42 deletions

View File

@ -61,7 +61,7 @@ class TriggerDebugEventBus:
Args:
tenant_id: Tenant ID for hash tag
event: Event object to dispatch
pool_key: Pool key (generate using event_class.build_pool_key(...))
pool_key: Pool key (generate using build_{?}_pool_key(...))
Returns:
Number of addresses the event was dispatched to
@ -98,7 +98,7 @@ class TriggerDebugEventBus:
Args:
event_class: Event class for deserialization and type safety
pool_key: Pool key (generate using event_class.build_pool_key(...))
pool_key: Pool key (generate using build_{?}_pool_key(...))
tenant_id: Tenant ID
user_id: User ID for address calculation
app_id: App ID for address calculation

View File

@ -9,7 +9,14 @@ from pydantic import BaseModel
from core.plugin.entities.request import TriggerInvokeEventResponse
from core.trigger.debug.event_bus import TriggerDebugEventBus
from core.trigger.debug.events import PluginTriggerDebugEvent, ScheduleDebugEvent, WebhookDebugEvent
from core.trigger.debug.events import (
PluginTriggerDebugEvent,
ScheduleDebugEvent,
WebhookDebugEvent,
build_plugin_pool_key,
build_schedule_pool_key,
build_webhook_pool_key,
)
from core.workflow.enums import NodeType
from core.workflow.nodes.trigger_plugin.entities import TriggerEventNodeData
from models.model import App
@ -49,7 +56,7 @@ class PluginTriggerDebugEventPoller(TriggerDebugEventPoller):
plugin_trigger_data = TriggerEventNodeData.model_validate(self.node_config.get("data", {}))
provider_id = TriggerProviderID(plugin_trigger_data.provider_id)
pool_key: str = PluginTriggerDebugEvent.build_pool_key(
pool_key: str = build_plugin_pool_key(
name=plugin_trigger_data.event_name,
provider_id=str(provider_id),
tenant_id=self.tenant_id,
@ -86,7 +93,7 @@ class PluginTriggerDebugEventPoller(TriggerDebugEventPoller):
class WebhookTriggerDebugEventPoller(TriggerDebugEventPoller):
def poll(self) -> TriggerDebugEvent | None:
pool_key = WebhookDebugEvent.build_pool_key(
pool_key = build_webhook_pool_key(
tenant_id=self.tenant_id,
app_id=self.app_id,
node_id=self.node_id,
@ -119,9 +126,7 @@ class WebhookTriggerDebugEventPoller(TriggerDebugEventPoller):
class ScheduleTriggerDebugEventPoller(TriggerDebugEventPoller):
def poll(self) -> TriggerDebugEvent | None:
pool_key: str = ScheduleDebugEvent.build_pool_key(
tenant_id=self.tenant_id, app_id=self.app_id, node_id=self.node_id
)
pool_key: str = build_schedule_pool_key(tenant_id=self.tenant_id, app_id=self.app_id, node_id=self.node_id)
schedule_event: ScheduleDebugEvent | None = TriggerDebugEventBus.poll(
event_type=ScheduleDebugEvent,
pool_key=pool_key,

View File

@ -1,9 +1,18 @@
from collections.abc import Mapping
from enum import StrEnum
from typing import Any
from pydantic import BaseModel, Field
class TriggerDebugPoolKey(StrEnum):
"""Trigger debug pool key."""
SCHEDULE = "schedule_trigger_debug_waiting_pool"
WEBHOOK = "webhook_trigger_debug_waiting_pool"
PLUGIN = "plugin_trigger_debug_waiting_pool"
class BaseDebugEvent(BaseModel):
"""Base class for all debug events."""
@ -16,16 +25,15 @@ class ScheduleDebugEvent(BaseDebugEvent):
node_id: str
inputs: Mapping[str, Any]
@classmethod
def build_pool_key(cls, tenant_id: str, app_id: str, node_id: str) -> str:
"""Generate pool key for schedule events.
Args:
tenant_id: Tenant ID
app_id: App ID
node_id: Node ID
"""
return f"schedule_trigger_debug_waiting_pool:{tenant_id}:{app_id}:{node_id}"
def build_schedule_pool_key(tenant_id: str, app_id: str, node_id: str) -> str:
"""Generate pool key for schedule events.
Args:
tenant_id: Tenant ID
app_id: App ID
node_id: Node ID
"""
return f"{TriggerDebugPoolKey.SCHEDULE}:{tenant_id}:{app_id}:{node_id}"
class WebhookDebugEvent(BaseDebugEvent):
@ -35,16 +43,16 @@ class WebhookDebugEvent(BaseDebugEvent):
node_id: str
payload: dict[str, Any] = Field(default_factory=dict)
@classmethod
def build_pool_key(cls, tenant_id: str, app_id: str, node_id: str) -> str:
"""Generate pool key for webhook events.
Args:
tenant_id: Tenant ID
app_id: App ID
node_id: Node ID
"""
return f"webhook_trigger_debug_waiting_pool:{tenant_id}:{app_id}:{node_id}"
def build_webhook_pool_key(tenant_id: str, app_id: str, node_id: str) -> str:
"""Generate pool key for webhook events.
Args:
tenant_id: Tenant ID
app_id: App ID
node_id: Node ID
"""
return f"{TriggerDebugPoolKey.WEBHOOK}:{tenant_id}:{app_id}:{node_id}"
class PluginTriggerDebugEvent(BaseDebugEvent):
@ -56,14 +64,14 @@ class PluginTriggerDebugEvent(BaseDebugEvent):
subscription_id: str
provider_id: str
@classmethod
def build_pool_key(cls, tenant_id: str, provider_id: str, subscription_id: str, name: str) -> str:
"""Generate pool key for plugin trigger events.
Args:
name: Event name
tenant_id: Tenant ID
provider_id: Provider ID
subscription_id: Subscription ID
"""
return f"plugin_trigger_debug_waiting_pool:{tenant_id}:{str(provider_id)}:{subscription_id}:{name}"
def build_plugin_pool_key(tenant_id: str, provider_id: str, subscription_id: str, name: str) -> str:
"""Generate pool key for plugin trigger events.
Args:
name: Event name
tenant_id: Tenant ID
provider_id: Provider ID
subscription_id: Subscription ID
"""
return f"{TriggerDebugPoolKey.PLUGIN}:{tenant_id}:{str(provider_id)}:{subscription_id}:{name}"