Design and Implementation of a Configurable Real-Time Rule Engine for Live‑Streaming Product Audits
The paper presents a configurable real‑time rule engine for live‑streaming product audits that decouples data aggregation from rule execution, uses QLExpress for dynamic conditions, supports Dubbo and HTTP sources, and enables safe gray‑release updates, cutting the rule‑change cycle from weeks to near‑real‑time.
Background: Live‑streaming e‑commerce has become a major consumption scenario, reshaping the traditional product‑consumer‑store relationship. As a SaaS provider, Youzan connects merchants to various live‑streaming channels (Kuaishou, Weibo, Huya, etc.) and must enforce each channel's product‑audit rules, which vary widely. A generic rule platform is needed to handle these diverse and evolving audit requirements.
Historical Process & Pain Points: The original workflow relied on hard‑coded validation rules accessed via a query interface. Any rule change required code modification, triggering a full release and regression testing cycle. Key issues were: Inflexible audit rules that could not be quickly adjusted. Rule changes depended on code releases, leading to long change cycles. Complex regression testing without support for gray releases.
Goal: Replace code‑centric rule maintenance with a fully configurable system that supports gray‑release deployment, thereby simplifying the change process and reducing risk.
Overall Design: The solution consists of two major modules – a real‑time data aggregation service and a rule execution system. These modules can operate independently or be combined to form a complete rule platform.
Real‑Time Data Aggregation: The engine starts with minimal input (e.g., a product ID) and must gather additional attributes such as product type and category. It calls various third‑party interfaces (Dubbo, HTTP) whose request parameters and response structures are also configurable. The calls can be arranged in parallel or serially depending on dependency relationships.
Data Source Integration: Supports both Dubbo generic calls and HTTP APIs. For Dubbo, the service name, method name, and request template are defined in configuration, and the response is parsed to extract required fields.
Rule System – Rule Model: Each condition consists of a left value, an operator, and a right value. Multiple conditions are combined with logical expressions to form a rule, and rules can be grouped in parallel. Left values are typically fields from the aggregated data; operators include standard comparisons (>, <, ==, !=) and custom functions registered in QLExpress. Right values are usually thresholds or other data fields. Custom text can be generated using QLExpress functions to concatenate data fields.
Execution Engine: The lightweight QLExpress engine is chosen for its dynamic scripting capabilities. It handles operator support, custom function registration, and script‑based text generation. Expressions can use standard comparison symbols and also invoke advanced functions such as regex matching, string‑in checks, or even remote Dubbo calls.
Gray Release Process: While configuration makes rule changes easy, a robust verification workflow is required. All rule modifications go through a gray‑release pipeline that validates rule syntax and then tests logical correctness in a staged environment before full rollout.
Summary: Configurable rules replace hard‑coded validation logic, cutting the change cycle from a week‑long release process to near‑real‑time updates. The gray‑release mechanism ensures safe deployments. The data aggregation and rule execution components are fully decoupled, enabling reuse in other scenarios. Future work includes structured logging, log analytics, and real‑time monitoring of data sources.
Youzan Coder
Official Youzan tech channel, delivering technical insights and occasional daily updates from the Youzan tech team.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.