wizbii/pipeline

本包最新版本(dev-master)的许可证信息不可用。

dev-master 2022-02-23 10:30 UTC

README

Build Status

Alpha 发布版

项目目标

Wizbii 的 Pipeline 是一个用于处理后端流程的框架。这里的“流程”指的是在事件发生后需要执行的一系列操作。Pipeline 被设计成可以表示为一张图。它提供了一个 JSON API 来获取图细节。在几周内,我们将发布一个使用此 API 的第一个版本 webapp,以帮助展示此 API。它的目的是作为一个架构文档使用。

我们在 Wizbii 使用 Pipeline 与我们的 CQRS 方法结合使用,以处理我们的数据。

主要架构

架构被分解为几个参与者

  • 事件 : 事件被抛出到或从类似 RabbitMQ、HornetQ 的消息系统中捕获。它只包含少量信息,因为它在网络中传输。为了简单和一致性,事件不像大多数事件溯源解决方案那样持久化。
  • 操作 : 操作是事件的内部表示。它由调度器发送到已注册的存储。由于操作仅存在于内存中,它可以包含比简单事件更多的信息。操作在捕获事件后创建。
  • 存储 : 存储负责管理投影。每个存储在创建操作或另一个存储完成任务后注册以运行。在 Symfony 世界中,存储通过服务实现。

安装

配置

要配置 Pipeline,您可以在主 config.yml 文件中定义一个简单的 YML 文件。下面是此文件的参考。

# Default configuration for extension with alias: "wizbii_pipeline"
wizbii_pipeline:
    actions:

        # Prototype
        name:
            triggered_by_events:  []
    stores:

        # Prototype
        name:
            service:              ~
            triggered_by_actions: []
            triggered_by_stores:  []
            triggered_events:     []

在社交网络环境下的此类文件的一个非常简单的示例

wizbii_pipeline:
    actions:
        profile_updated: ~
        profile_anniversary: ~
        profile_new_friends:
            triggered_by_events: [profile_new_connection, profile_friends_new_connection, profile_new_school, profile_school_new_student]
        profile_update_thanx: ~

    stores:
        # This store updates the projection containing profile network : friends, friends of friends and school friends
        profile_network:
            service: wizbii.pipeline.stores.profile.network
            triggered_by_actions: [profile_new_friends]

        # This store updates the projection containing profile thanxers
        profile_thanx:
            service: wizbii.pipeline.stores.profile.network
            triggered_by_actions: [profile_update_thanx]

        # This store updates the projection containing profile identity card : first_name, last_name, title, age, network
        # and thanx counters
        profile_identity_card:
            service: wizbii.pipeline.stores.profile.identity_card
            triggered_by_actions: [profile_updated, profile_anniversary]
            triggered_by_stores: [profile_network, profile_thanx]

        # This store updates the projection containing profile proxy
        profile_proxy:
            service: wizbii.pipeline.stores.profile.profile_proxy
            triggered_by_actions: [profile_updated, profile_anniversary]
            triggered_by_stores: [profile_network, profile_thanx]

        # This store updates the projection containing profile stats
        profile_stats:
            service: wizbii.pipeline.stores.profile.profile_stats
            triggered_by_actions: [profile_updated, profile_anniversary]
            triggered_by_stores: [profile_network, profile_thanx]

        # This store updates the projection containing ESProfile. Indexation in ElasticSearch is done asynchronously
        profile_search:
            service: wizbii.pipeline.stores.profile.profile_search
            triggered_by_actions: [profile_updated, profile_anniversary]
            triggered_by_stores: [profile_network, profile_thanx]
            triggered_events: [esprofile_updated]