JSPM

@flowlab/all

0.0.2
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 4
  • Score
    100M100P100Q32820F
  • License MIT

A cool library focusing on handling various flows

Package Exports

    This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@flowlab/all) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

    Readme

    FlowLab

    FlowLab 是一个功能强大的工作流管理框架,支持多种流类型的编排与调度,旨在帮助开发者实现高效的任务自动化、事件流处理、消息调度、数据管道等。无论是简单的任务链还是复杂的多路径工作流,FlowLab 都能提供完美的解决方案。

    📦 安装

    通过 npm 安装:

    npm install @flowlab/all

    🚀 快速开始

    FlowLab 提供了简单易用的 API,您可以轻松开始构建和管理工作流。

    创建一个简单的工作流

    import { FlowLab } from '@flowlab/flowlab';
    
    // 创建一个新的工作流
    const workflow = FlowLab.create('myWorkflow');
    
    // 添加节点
    workflow
      .addStep('step1', async () => {
        console.log('Step 1 executed');
        return 'Step 1 result';
      })
      .addStep('step2', async (resultFromStep1) => {
        console.log(`Step 2 received: ${resultFromStep1}`);
        return 'Step 2 result';
      })
      .run()
      .then(result => {
        console.log('Workflow completed with result:', result);
      })
      .catch(err => {
        console.error('Workflow failed with error:', err);
      });

    使用并行任务

    FlowLab 支持并行任务的执行,只需使用 addParallelStep 方法:

    workflow
      .addParallelStep('parallel1', async () => {
        console.log('Parallel Task 1');
        return 'Result of parallel task 1';
      })
      .addParallelStep('parallel2', async () => {
        console.log('Parallel Task 2');
        return 'Result of parallel task 2';
      })
      .run()
      .then(result => {
        console.log('Workflow completed with parallel results:', result);
      });

    使用子工作流

    FlowLab 还支持将子工作流嵌套在主工作流中:

    const childWorkflow = FlowLab.create('childWorkflow')
      .addStep('childStep', async () => {
        console.log('Child workflow executed');
        return 'Child result';
      });
    
    workflow
      .addSubWorkflow('childWorkflow', childWorkflow)
      .run()
      .then(result => {
        console.log('Parent workflow completed with child result:', result);
      });

    🔑 功能概览

    核心功能: • DAG 编排:支持任务链和自动化调度,保证依赖关系的正确性。 • 任务管理:内置节点执行、状态跟踪、条件判断等功能。 • 事件驱动:基于事件触发的工作流,支持多种异步任务管理。 • 并行执行:支持并行任务执行和结果合并。 • 子工作流支持:通过嵌套子工作流,实现更复杂的任务链。 • 错误处理:任务失败时支持重试、回滚和补偿机制。

    🔄 高级功能 • 动态条件分支:根据条件动态调整工作流路径。 • SLA 监控:为任务设置 SLA 超时监控。 • 多租户支持:支持不同租户的数据隔离与权限控制。 • 消息流管理:结合消息队列系统(如 RabbitMQ、Kafka),实现分布式消息推送与消费。

    🔧 开发者文档

    FlowLab 提供了完善的开发者文档,帮助您更深入地了解工作流管理和使用。文档包括: • 工作流设计:如何创建、设计、管理工作流。 • 高级功能:如何使用动态分支、子工作流、条件逻辑等高级特性。 • 事件和消息流:如何使用事件触发器和消息流管理任务。

    您可以访问 FlowLab 官方文档 了解更多信息。

    🤝 贡献

    此代码库未来还有很大的拓展空间,我们欢迎社区成员对 FlowLab 提供贡献。如果您发现 bug 或有新功能建议,欢迎提起 Issue,并通过 Pull Request 贡献代码。

    📄 许可证

    FlowLab 使用 MIT 许可证,可以自由使用和修改。

    总结

    FlowLab 是一个灵活且高效的工作流引擎,支持多种流类型的任务管理,能够帮助开发者设计复杂的任务流和事件驱动的自动化流程。它的易用性和扩展性使得它适用于多种场景,从简单的任务链到复杂的分布式任务调度,都能轻松应对。