deer-flow/backend/packages/harness/deerflow/config/dedupe_storage_config.py
Zhipeng Zheng 838037188e
feat(channels): share inbound webhook dedupe across pods via Postgres (#4210)
* feat(channels): share inbound webhook dedupe across pods via Postgres (#4120)

* ci: run cross-pod inbound dedupe integration tests in CI

Expose the job Postgres service via DEDUPE_TEST_POSTGRES_URL so the integration tests (issue #4120) actually execute instead of silently skipping. Normalize the URL for asyncpg (postgresql:// -> +asyncpg, drop libpq-only sslmode) and await the now-async _is_duplicate_inbound in test_github_dispatcher.
2026-07-27 23:07:40 +08:00

42 lines
1.4 KiB
Python

"""Configuration for inbound webhook dedupe storage.
Controls where the ChannelManager's inbound dedupe state lives. See issue #4120
(cross-pod webhook dedupe). The default ``auto`` reuses the Postgres application
database whenever database.backend='postgres', otherwise an in-process memory
store. ``memory`` is per-pod and not shared across replicas; ``postgres`` shares
state across pods.
"""
from __future__ import annotations
from enum import StrEnum
from pydantic import BaseModel, Field
from deerflow.config.reload_boundary import format_field_description
class DedupeStorageBackend(StrEnum):
AUTO = "auto"
MEMORY = "memory"
POSTGRES = "postgres"
class DedupeStorageConfig(BaseModel):
"""Where inbound webhook dedupe state lives."""
backend: DedupeStorageBackend = Field(
default=DedupeStorageBackend.AUTO,
description=format_field_description(
"dedupe_storage",
field_doc=(
"Storage backend for inbound webhook dedupe state. "
"'auto' uses the Postgres application database whenever database.backend='postgres', "
"otherwise an in-process memory store (single-pod). "
"'memory' forces the in-process store (per-pod; not shared across replicas). "
"'postgres' shares dedupe state across pods via the application database. "
"See issue #4120."
),
),
)