承接 aldidigitalservices/lean-publisher 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

aldidigitalservices/lean-publisher

Composer 安装命令:

composer require aldidigitalservices/lean-publisher

包简介

Lean publishing module for Spryker

README 文档

README

Description

The Lean Publisher is a publication process that is based on sprykers "Publish & Synchronize" process (https://docs.spryker.com/docs/scos/dev/back-end-development/data-manipulation/data-publishing/publish-and-synchronization.html).

The goal of this process is to make data available in the frontend-centric data storages like Redis and Elasticsearch.

The Lean Publisher is meant to be used in connection with a spryker system.

Screenshot

Benefits

  1. Lean publisher centralizes all writing operations so that the connected modules do not need to think about bulk publishing
  2. The synchronization into Redis and Elasticsearch happens synchronously - preventing out of sync storage data
  3. The amount of queues, events and messages is drastically reduced which improves the performance of the RabbitMQ in high throughput environments
  4. The event mapping is improved and centralized in one place. Making the connection of the publisher processes easier to understand
  5. Provides a guiding structure for the implementing modules, so that there is not too many different approaches to publishing

Installation

composer require ALDIDigitalservices/lean-publisher

Integration

config_default.php

add "ALDIDigitalServices" to your CORE_NAMESPACES in config_default.php

$config[KernelConstants::CORE_NAMESPACES] = [
	...
	'ALDIDigitalServices',
	...
];

Console

In src/Pyz/Zed/Console/ConsoleDependencyProvider.php please register

[...]
new LeanPublisherResynchronizationConsole(),
[...]

Available commands:

docker/sdk console lean-publisher:sync $RESOURCE $IDS

with $RESOURCE beeing the resource you want to publish

and $IDS beeing a list of comma separated entity ids to publish

Event

In src/Pyz/Zed/Event/EventDependencyProvider.php register

[...]
$eventSubscriberCollection->add(new LeanPublisherEventSubscriber());
[...]

Connecting your module to the Lean Publisher

If you want to connect your entity to the Lean Publisher you need to follow these steps:

Step 1: Create your publishing module

We suggest starting a module with "<ENTITY_NAME>Publish". So for example CategoryPublish, MerchantPublish etc.

Step 2: Create a new queue + retry queue

in src/Pyz/Zed/Queue/QueueDependencyProvider.php using the LeanPublisherQueueMessageProcessorPlugin

[...]
<ENTITY_NAME>PublishConfig::PUBLISH_MY_ENTITY_QUEUE_NAME => new LeanPublisherQueueMessageProcessorPlugin(),
<ENTITY_NAME>PublishConfig::PUBLISH_MY_ENTITY_RETRY_QUEUE_NAME => new EventRetryQueueMessageProcessorPlugin()
[...]

Step 3: Register retry and error configuration in

In src/Pyz/Client/RabbitMq/RabbitMqConfig.php add

[...]
<ENTITY_NAME>PublishConfig::PUBLISH_<MY_ENTITY>_QUEUE_NAME => [
    static::ROUTING_KEY_RETRY => <ENTITY_NAME>PublishConfigConfig::PUBLISH_<ENTITY_NAME>_RETRY_QUEUE_NAME,
    static::ROUTING_KEY_ERROR => <ENTITY_NAME>PublishConfigConfig::PUBLISH_<ENTITY_NAME>_ERROR_QUEUE_NAME,
],
[...]

Setup the new registered queue via console command. docker/sdk console queue:setup

Step 4: Create a database table that follows the Lean Publisher conventions

<?xml version="1.0"?>
<database xmlns="spryker:schema-01" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="zed"
          xsi:schemaLocation="spryker:schema-01 https://static.spryker.com/schema-01.xsd"
          namespace="Orm\Zed\<MyModule>\Persistence"
          package="src.Orm.Zed.<MyModule>.Persistence">

    <table name="MY_ENTITY_publish" identifierQuoting="true">
        <column name="id_MY_ENTITY_publish" required="true" type="INTEGER" autoIncrement="true"
                primaryKey="true"/>
        <column name="reference" required="true" type="VARCHAR" size="255"/>
        <column name="key_search" type="VARCHAR" size="255"/>
        <column name="key_storage" type="VARCHAR" size="255"/>
        <column name="data_search" type="LONGVARCHAR"/>
        <column name="data_storage" type="LONGVARCHAR"/>
        <column name="store" type="VARCHAR" size="128" required="true"/>

        <index name="MY_ENTITY_publish-reference">
            <index-column name="reference"/>
        </index>

        <unique name="MY_ENTITY_publish-unique-key_storage">
            <unique-column name="key_storage"/>
        </unique>
        <unique name="MY_ENTITY_publish-unique-key_search">
            <unique-column name="key_search"/>
        </unique>

        <id-method-parameter value="id_MY_ENTITY_publish_pk_seq"/>

        <behavior name="timestampable"/>
    </table>

</database>

Create the new table via the console command:

docker/sdk console propel:schema:copy && docker/sdk console propel:model:build && docker/sdk console propel:diff && docker/sdk console propel:migrate && docker/sdk console transfer:entity:generate

Step 5: Create an EventHandler Plugin that implements Lean Publisher Interfaces

Interface Description
LeanPublisherEventHandlerPluginInterface general Lean Publisher event handler interface. Needed for communication with the Lean Publisher.
LeanPublisherStoragePublishPluginInterface If you want to publish to storage, you need this interface.
LeanPublisherSearchPublishPluginInterface If you want to publish to search, you need this interface.

Step 6: Register the EventHandler

In src/Pyz/Zed/LeanPublisher/LeanPublisherDependencyProvider.php::getEventHandlerPlugins()

return [
    [...]
    <ENTITY_NAME>PublishConfig::PUBLISH_<ENTITY_NAME>_QUEUE_NAME => new <ENTITY_NAME>PublishEventHandlerPlugin(),
    [...]
];

Step 7: Create and register a PublisherTriggerPlugin

Create a PublishTriggerPlugin implementing both PublisherTriggerPluginInterface, LeanPublisherTriggerPluginInterface and set it up in \Pyz\Zed\Publisher\PublisherDependencyProvider::getPublisherTriggerPlugins

return [
    [...]
     new <ENTITY_NAME>PublishPublisherTriggerPlugin(),
     [...]
];

Step 8: Set up jobs to process the events

Depending on your setup you need to add jenkins jobs or other jobs to process messages from your publish.ENTITY_NAME queue

aldidigitalservices/lean-publisher 适用场景与选型建议

aldidigitalservices/lean-publisher 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.1k 次下载、GitHub Stars 达 3, 最近一次更新时间为 2023 年 02 月 24 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 aldidigitalservices/lean-publisher 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 aldidigitalservices/lean-publisher 我们能提供哪些服务?
定制开发 / 二次开发

基于 aldidigitalservices/lean-publisher 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 1.1k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 3
  • 点击次数: 7
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 3
  • Watchers: 3
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-02-24