class DataProcessingModel extends FlowModel {}
// 注册模型类
engine.registerModel('DataProcessingModel', DataProcessingModel);
// 创建模型实例
const model = engine.createModel({
uid: 'data-processing-001',
use: 'DataProcessingModel',
props: {
title: 'Data Processing Instance',
description: 'Processes user data with advanced algorithms',
config: {
algorithm: 'neural-network',
batchSize: 100,
learningRate: 0.01
},
metadata: {
version: '2.1.0',
author: 'Data Team',
createdAt: new Date().toISOString()
}
},
stepParams: {
loadData: {
source: 'database',
query: 'SELECT * FROM users WHERE active = true',
limit: 1000
},
preprocess: {
normalize: true,
removeOutliers: true,
encoding: 'utf8'
},
process: {
algorithm: 'neural-network',
layers: [64, 32, 16],
epochs: 100,
batchSize: 32
},
saveResults: {
destination: 'results_table',
format: 'json',
compress: true
}
},
subModels: {
dataSources: [
{
use: 'DatabaseSource',
props: {
name: 'Primary DB',
connection: 'mysql://localhost:3306/db1'
}
},
{
use: 'APISource',
props: {
name: 'External API',
url: 'https://api.external.com/data'
}
}
],
processors: [
{
use: 'DataProcessor',
props: {
name: 'Main Processor',
type: 'neural-network'
}
}
],
outputHandler: {
use: 'OutputHandler',
props: {
name: 'Results Handler',
format: 'json'
}
}
},
flowRegistry: {
'dataProcessingFlow': {
title: 'Data Processing Flow',
manual: false,
sort: 0,
steps: {
load: {
use: 'loadDataAction',
title: 'Load Data',
sort: 0
},
process: {
use: 'processDataAction',
title: 'Process Data',
sort: 1
},
save: {
use: 'saveDataAction',
title: 'Save Results',
sort: 2
}
}
},
'errorHandlingFlow': {
title: 'Error Handling Flow',
manual: true,
on: 'error',
steps: {
log: {
use: 'logErrorAction',
title: 'Log Error'
},
notify: {
use: 'notifyErrorAction',
title: 'Notify Admin'
}
}
}
}
});
// 使用模型
model.applyFlow('dataProcessingFlow');