Ice Rule Engine Project Structure
Source code analysis of Ice rule engine - understanding core modules and code organization
Ice Rule Engine Module Overview
Ice 2.0 adopts a Monorepo architecture, managing multi-language SDKs uniformly with clear module responsibilities, making it easy to understand and extend.
ice/ # GitHub: github.com/zjn-zjn/ice
├── sdks/ # Multi-language SDKs
│ ├── java/ # Java SDK
│ │ ├── ice-common/ # Common module
│ │ │ ├── constant/ # Constant definitions
│ │ │ ├── dto/ # Data transfer objects
│ │ │ ├── enums/ # Enum definitions
│ │ │ └── model/ # Model classes
│ │ ├── ice-core/ # Rule engine core ⭐
│ │ │ ├── annotation/ # Annotation definitions
│ │ │ ├── base/ # Node base classes
│ │ │ ├── cache/ # Config cache
│ │ │ ├── client/ # File client
│ │ │ └── context/ # Execution context
│ │ └── ice-spring-boot/ # SpringBoot integration
│ │ ├── ice-spring-boot-starter-2x/
│ │ └── ice-spring-boot-starter-3x/
│ ├── go/ # Go SDK (v1.0.1)
│ │ ├── cache/ # Config cache
│ │ ├── client/ # File client
│ │ ├── context/ # Execution context
│ │ ├── node/ # Node implementation
│ │ └── relation/ # Relation nodes
│ └── python/ # Python SDK
│ └── src/ice/
│ ├── cache/ # Config cache
│ ├── client/ # File client
│ ├── context/ # Execution context
│ ├── node/ # Node implementation
│ └── relation/ # Relation nodes
├── server/ # Config management server
│ └── ice-server/
│ ├── controller/ # Interface layer
│ ├── service/ # Business layer
│ └── storage/ # Storage layer
└── tests/ # Test examples
├── java/ # Java tests
├── go/ # Go tests
└── python/ # Python tests
Core Module Descriptions
ice-common - Common Module
Common component library for Ice rule engine:
- constant/ - Constant definitions
Constant- General constantsIceStorageConstants- File storage constants (2.0 new)
- dto/ - Data transfer objects
IceBaseDto/IceConfDto- Rule config DTOsIceTransferDto- Config transfer DTOIceClientInfo- Client information (2.0 new)IceAppDto/IcePushHistoryDto- App and publish history
- enums/ - Enum definitions
- model/ - Model classes
ice-core - Rule Engine Core ⭐
Core implementation of Ice rule engine, highly recommended to read:
1. annotation Package - Annotation Definitions
@IceNode- Node annotation, defines node name, description, order@IceField- Field annotation, defines field name, description, type@IceIgnore- Ignore annotation, marks fields not shown in config UI
2. base Package - Node Base Classes ⭐⭐⭐
Core base classes of Ice rule engine node system:
- BaseNode - Base class for all rule nodes
- Node lifecycle management
- Time control (effective time)
- Error handling
- BaseLeaf - Base class for all leaf nodes
BaseLeafFlow- Flow node base classBaseLeafResult- Result node base classBaseLeafNone- None node base class
- BaseRelation - Base class for all relation nodes
- AND / ANY / ALL / NONE / TRUE
3. cache Package - Rule Engine Cache ⭐⭐⭐
- IceConfCache - Rule node cache
- Node initialization and instantiation
- Rule tree construction
- Config hot update
- IceHandlerCache - Handler cache
- Index by iceId
- Index by scene
4. client Package - Client Implementation (2.0 Refactored)
- IceFileClient - File system based client ⭐
- Load config from file system
- Version polling for updates
- Heartbeat reporting
- Incremental/full config loading
- IceLeafScanner - Leaf node scanner
- IceUpdate - Config update handler
5. context Package - Execution Context
- IceContext - Rule execution context
- IcePack - Execution pack, passed when triggering
- IceRoam - Data storage (ConcurrentHashMap extension)
6. Execution Entry
- Ice - Entry class
Start reading source code from here~syncProcess()- Synchronous executionasyncProcess()- Asynchronous execution
- IceDispatcher - Rule dispatcher
ice-server - Config Management Server
Configuration management platform for Ice rule engine:
Core Directories
- controller/ - Interface layer
IceAppController- App managementIceBaseController- Rule listIceConfController- Node configuration
- service/ - Business layer
IceAppService- App serviceIceBaseService- Rule serviceIceConfService- Config serviceIceServerService- Server core logic
- storage/ - Storage layer (2.0 new) ⭐
IceFileStorageService- File storage serviceIceClientManager- Client managerIceIdGenerator- ID generator
2.0 Architecture Changes
- ✅ Added
storage/package - File storage implementation - ❌ Removed
dao/package - MyBatis no longer needed - ❌ Removed
nio/package - NIO communication no longer needed
ice-spring-boot - SpringBoot Integration
ice-spring-boot-starter-2x
Starter for SpringBoot 2.x:
IceClientProperties- Configuration propertiesIceFileClientInit- Client initialization (2.0 new)
ice-spring-boot-starter-3x
Starter for SpringBoot 3.x, same structure as 2x.
ice-test - Test Examples
Provides complete usage examples, including:
- Leaf node examples (Flow/Result/None)
- Configuration file examples
- Rule execution examples
Source Code Reading Suggestions
Beginner Path
- ice-test - Run examples first, understand basic usage
- Ice.java - Start from execution entry
- IceDispatcher - Understand rule dispatching logic
- BaseNode/BaseRelation/BaseLeaf - Understand node system
Advanced Path
- IceConfCache - Config cache and rule tree construction
- IceFileClient - Client implementation (2.0)
- IceFileStorageService - File storage implementation (2.0)
Recommended Core Classes ⭐
| Class | Description | Rating |
|---|---|---|
Ice | Execution entry | ⭐⭐⭐ |
BaseNode | Node base class | ⭐⭐⭐ |
IceConfCache | Config cache | ⭐⭐⭐ |
IceFileClient | File client | ⭐⭐ |
IceFileStorageService | File storage | ⭐⭐ |