From 3a183371297788cd453cf6f08b1b8d325a708d2f Mon Sep 17 00:00:00 2001 From: Yeuoly Date: Sat, 18 Oct 2025 19:47:23 +0800 Subject: [PATCH] refactor: confused abstract class --- api/core/trigger/debug/event_selectors.py | 2 +- api/core/trigger/debug/events.py | 34 ++++------------------- 2 files changed, 6 insertions(+), 30 deletions(-) diff --git a/api/core/trigger/debug/event_selectors.py b/api/core/trigger/debug/event_selectors.py index ce7d0a27ce..da507735bd 100644 --- a/api/core/trigger/debug/event_selectors.py +++ b/api/core/trigger/debug/event_selectors.py @@ -51,7 +51,7 @@ class PluginTriggerDebugEventPoller(TriggerDebugEventPoller): provider_id = TriggerProviderID(plugin_trigger_data.provider_id) pool_key: str = PluginTriggerDebugEvent.build_pool_key( name=plugin_trigger_data.event_name, - provider_id=provider_id, + provider_id=str(provider_id), tenant_id=self.tenant_id, subscription_id=plugin_trigger_data.subscription_id, ) diff --git a/api/core/trigger/debug/events.py b/api/core/trigger/debug/events.py index 3d461b506b..ea7bc986b2 100644 --- a/api/core/trigger/debug/events.py +++ b/api/core/trigger/debug/events.py @@ -1,28 +1,14 @@ -from abc import ABC, abstractmethod from collections.abc import Mapping from typing import Any from pydantic import BaseModel, Field -class BaseDebugEvent(ABC, BaseModel): +class BaseDebugEvent(BaseModel): """Base class for all debug events.""" timestamp: int - @classmethod - @abstractmethod - def build_pool_key(cls, **kwargs: Any) -> str: - """ - Generate the waiting pool key for this event type. - - Each subclass implements its own pool key strategy based on routing parameters. - - Returns: - Redis key for the waiting pool - """ - raise NotImplementedError("Subclasses must implement build_pool_key") - class ScheduleDebugEvent(BaseDebugEvent): """Debug event for schedule triggers.""" @@ -31,7 +17,7 @@ class ScheduleDebugEvent(BaseDebugEvent): inputs: Mapping[str, Any] @classmethod - def build_pool_key(cls, **kwargs: Any) -> str: + def build_pool_key(cls, tenant_id: str, app_id: str, node_id: str) -> str: """Generate pool key for schedule events. Args: @@ -39,9 +25,6 @@ class ScheduleDebugEvent(BaseDebugEvent): app_id: App ID node_id: Node ID """ - tenant_id = kwargs["tenant_id"] - app_id = kwargs["app_id"] - node_id = kwargs["node_id"] return f"schedule_trigger_debug_waiting_pool:{tenant_id}:{app_id}:{node_id}" @@ -53,7 +36,7 @@ class WebhookDebugEvent(BaseDebugEvent): payload: dict[str, Any] = Field(default_factory=dict) @classmethod - def build_pool_key(cls, **kwargs: Any) -> str: + def build_pool_key(cls, tenant_id: str, app_id: str, node_id: str) -> str: """Generate pool key for webhook events. Args: @@ -61,9 +44,6 @@ class WebhookDebugEvent(BaseDebugEvent): app_id: App ID node_id: Node ID """ - tenant_id = kwargs["tenant_id"] - app_id = kwargs["app_id"] - node_id = kwargs["node_id"] return f"webhook_trigger_debug_waiting_pool:{tenant_id}:{app_id}:{node_id}" @@ -77,7 +57,7 @@ class PluginTriggerDebugEvent(BaseDebugEvent): provider_id: str @classmethod - def build_pool_key(cls, **kwargs: Any) -> str: + 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: @@ -86,8 +66,4 @@ class PluginTriggerDebugEvent(BaseDebugEvent): provider_id: Provider ID subscription_id: Subscription ID """ - tenant_id = kwargs["tenant_id"] - provider_id = kwargs["provider_id"] - subscription_id = kwargs["subscription_id"] - event_name = kwargs["name"] - return f"plugin_trigger_debug_waiting_pool:{tenant_id}:{str(provider_id)}:{subscription_id}:{event_name}" + return f"plugin_trigger_debug_waiting_pool:{tenant_id}:{str(provider_id)}:{subscription_id}:{name}"