chimera/bus-tactician
Composer 安装命令:
composer require chimera/bus-tactician
包简介
Service bus adapter for league/tactician
README 文档
README
The term Chimera (/kɪˈmɪərə/ or /kaɪˈmɪərə/) has come to describe any mythical or fictional animal with parts taken from various animals, or to describe anything composed of very disparate parts, or perceived as wildly imaginative, implausible, or dazzling.
There are many many amazing libraries in the PHP community and with the creation and adoption of the PSRs we don't necessarily need to rely on full stack frameworks to create a complex and well designed software. Choosing which components to use and plugging them together can sometimes be a little challenging.
The goal of this set of packages is to make it easier to do that (without compromising the quality), allowing you to focus on the behaviour of your software.
This project provides an implementation for chimera/foundation that
uses league/tactician as service bus.
Installation
Package is available on Packagist, you can install it using Composer.
composer require chimera/bus-tactician
Usage
The only thing you need to do in order to plug tactician into chimera is to create an instance of the command bus as you usually do and pass it to the decorator:
<?php use Chimera\ServiceBus\Tactician\ServiceBus; use League\Tactician\CommandBus; $middlewareList = []; // list of middleware to be used to process commands $commandBus = new ServiceBus(new CommandBus($middlewareList));
Usually the write and read concerns have different needs, which means that the list of middleware will definitely vary, so it's highly suggested that you create two service buses: a query bus and a command bus:
<?php use Chimera\ServiceBus\Tactician\ServiceBus; use League\Tactician\CommandBus; $writeMiddleware = []; // list of middleware to be used to process commands $commandBus = new ServiceBus(new CommandBus($writeMiddleware)); $readMiddleware = []; // list of middleware to be used to process queries $queryBus = new ServiceBus(new CommandBus($readMiddleware));
Domain to read model conversion
It's a good practice to completely isolate your domain model from your read model (also known as response model). This is important to prevent UI components (e.g.: request handlers - HTTP controllers - or CLI commands) from manipulating your aggregate roots and entities.
We provide the ReadModelConversionMiddleware to handle such thing, and it should
be added to your query bus (since nothing is really returned from command buses):
<?php use Chimera\ServiceBus\ReadModelConverter\Callback; use Chimera\ServiceBus\Tactician\ReadModelConversionMiddleware; use Chimera\ServiceBus\Tactician\ServiceBus; use League\Tactician\CommandBus; // list of middleware to be used to process queries $readMiddleware = [ // many different middleware according to your needs new ReadModelConversionMiddleware(new Callback()), // you can use different strategies if needed // the handler locator middleware provided by tactician ]; $queryBus = new ServiceBus(new CommandBus($readMiddleware));
License
MIT, see LICENSE.
chimera/bus-tactician 适用场景与选型建议
chimera/bus-tactician 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 131.22k 次下载、GitHub Stars 达 3, 最近一次更新时间为 2018 年 05 月 05 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 chimera/bus-tactician 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 chimera/bus-tactician 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 131.22k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 5
- 依赖项目数: 1
- 推荐数: 1
其他信息
- 授权协议: MIT
- 更新时间: 2018-05-05