flux-eco/projection
Composer 安装命令:
composer require flux-eco/projection
包简介
Creates projections of aggregate root objects
README 文档
README
This component is responsible for projections of aggregate root objects. The projections are described as json schemas.
Usage
.env
PROJECTION_APP_SCHEMA_DIRECTORY=../schemas
PROJECTION_ECO_SCHEMA_DIRECTORY=schemas/projections
PROJECTION_STORAGE_CONFIG_ENV_PREFIX=PROJECTION_
PROJECTION_STORAGE_NAME=projection
PROJECTION_STORAGE_HOST=localhost
PROJECTION_STORAGE_DRIVER=Pdo_Mysql
PROJECTION_STORAGE_USER=user
PROJECTION_STORAGE_PASSWORD=password
STREAM_STORAGE_CONFIG_ENV_PREFIX=STREAM_
STREAM_STORAGE_NAME=stream
STREAM_STORAGE_HOST=localhost
STREAM_STORAGE_DRIVER=Pdo_Mysql
STREAM_STORAGE_USER=user
STREAM_STORAGE_PASSWORD=password
STREAM_TABLE_NAME=stream
STREAM_STATE_SCHEMA_FILE=../vendor/flux-eco/global-stream/schemas/State.yaml
schemas\domain\account.yaml
title: account
type: object
properties:
aggregateId:
type: string
readOnly: true
correlationId:
type: string
readOnly: true
aggregateName:
type: string
const: todo
readOnly: true
sequence:
type: integer
readOnly: true
createdDateTime:
type: string
format: date-time
readOnly: true
createdBy:
type: string
format: email
readOnly: true
changedDateTime:
type: string
format: date-time
readOnly: true
changedBy:
type: string
format: email
readOnly: true
rootObjectSchema:
type: string
const: v1
rootObject:
type: object
properties:
firstname:
type: string
lastname:
type: string
schemas\projections\account.yaml
title: account
type: object
aggregateRootNames:
- account
properties:
projectionId:
type: string
firstname:
type: string
index: account.rootObject.firstname
lastname:
type: string
index: account.rootObject.lastname
example.php
<?php
require_once __DIR__ . '/../vendor/autoload.php';
FluxEco\DotEnv\Api::new()->load(__DIR__);
//initialize
fluxProjection\initialize();
echo "projection storage initialized".PHP_EOL.PHP_EOL;
//getAggregateRootMappingsForProjectionData
$projectionName = 'account';
$projectionData = [
"firstname" => "Emmett",
"lastname" => "Brown",
];
$aggregateRootMappings = fluxProjection\getAggregateRootMappingsForProjectionData($projectionName, $projectionData);
echo 'getAggregateRootMappingsForProjectionData'.PHP_EOL.PHP_EOL;
print_r($aggregateRootMappings);
//receive aggregateRootStatePublished
$aggregateRootId = fluxValueObject\getNewUuid();
$aggregateRootName = 'account';
$messageName = 'aggregateRootCreated';
$jsonAggregateRootSchema = json_encode(yaml_parse(file_get_contents('schemas/domain/account.yaml')));
$payload = json_encode([
"firstname" => [
"value" => "Emmett",
"isEntityId" => false
],
"lastname" => [
"value" => "Brown",
"isEntityId" => false
]
]);
fluxProjection\receiveAggregateRootStatePublished(
$aggregateRootId,
$aggregateRootName,
$messageName,
$jsonAggregateRootSchema,
$payload
);
echo "aggregate root state published".PHP_EOL.PHP_EOL;
//get item list
echo "getItemList: ".PHP_EOL;
$projectionName = 'account';
$filter = [];
$itemList = fluxProjection\getItemList(
$projectionName,
$filter
);
print_r($itemList).PHP_EOL.PHP_EOL;
//getProjectionIdForAggregateId\
echo 'getProjectionIdForAggregateId '.PHP_EOL;
$projectionId = fluxProjection\getProjectionIdForAggregateId($projectionName, $aggregateRootId);
echo $projectionId.PHP_EOL.PHP_EOL;
//getAggregateIdForProjectionId
echo 'getAggregateIdForProjectionId: '.PHP_EOL;
$aggregateName = 'account';
$aggregateId = fluxProjection\getAggregateIdForProjectionId($projectionName, $projectionId, $aggregateName);
echo $aggregateId.PHP_EOL.PHP_EOL;
//getAggregateIdsForProjectionId
echo 'getAggregateIdsForProjectionId: '.PHP_EOL;
$aggregateIds = fluxProjection\getAggregateIdsForProjectionId($projectionName, $projectionId);
print_r($aggregateIds).PHP_EOL.PHP_EOL;
//getItem
echo "getItem: ".PHP_EOL;
$item = fluxProjection\getItem($projectionName, $projectionId);
print_r($item).PHP_EOL.PHP_EOL;
//register ExternalId
echo "registerExternalId: ".PHP_EOL.PHP_EOL;
$aggregateName = 'account';
$projectionName = 'account';
$externalId = '123';
fluxProjection\registerExternalId($aggregateName, $projectionName, $externalId);
//get AggregateId for ExternalId
echo "getAggregateIdForExternalId: ".PHP_EOL;
$aggregateName = 'account';
$projectionName = 'account';
$externalId = '123';
$aggregateId = fluxProjection\getAggregateIdForExternalId($aggregateName, $projectionName, $externalId);
echo $aggregateId.PHP_EOL.PHP_EOL;
//get ProjectionId for ExternalId
echo "getProjectionIdForExternalId: ".PHP_EOL;
$aggregateName = 'account';
$projectionName = 'account';
$externalId = '123';
$projectionId = fluxProjection\getProjectionIdForExternalId($aggregateName, $projectionName, $externalId);
echo $projectionId.PHP_EOL.PHP_EOL;
output
projection storage initialized
getAggregateRootMappingsForProjectionData
Array
(
[account] => Array
(
[firstname] => Emmett
[lastname] => Brown
)
)
aggregate root state published
getItemList:
Array
(
[0] => Array
(
[projectionId] => 20cdb2e1-b811-44b7-8f82-ce08d0338bb4
[firstname] => Emmett
[lastname] => Brown
)
)
getProjectionIdForAggregateId
6c6512a4-499a-427f-9070-b3e66bf35ab3
getAggregateIdForProjectionId:
6c8a642b-b7a0-48af-aaae-21564c0fe609
getAggregateIdsForProjectionId:
Array
(
[account] => 6c8a642b-b7a0-48af-aaae-21564c0fe609
)
getItem:
Array
(
[projectionId] => 6c6512a4-499a-427f-9070-b3e66bf35ab3
[firstname] => Emmett
[lastname] => Brown
)
registerExternalId:
getAggregateIdForExternalId:
2e9d3ad5-b727-49bf-9a60-47acc802a298
getProjectionIdForExternalId:
bc3a543e-d9c0-421f-bd21-3c5732ea8f29
Contributing 💜
Please ...
- ... register an account at https://git.fluxlabs.ch
- ... create pull requests 🔥
Adjustment suggestions / bug reporting 🐾
Please ...
- ... register an account at https://git.fluxlabs.ch
- ... ask us for a Service Level Agreement: support@fluxlabs.ch 😘
- ... read and create issues
flux-eco/projection 适用场景与选型建议
flux-eco/projection 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 53 次下载、GitHub Stars 达 0, 最近一次更新时间为 2022 年 03 月 27 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「projection」 「flux-eco」 「fluxlabs」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 flux-eco/projection 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 flux-eco/projection 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 flux-eco/projection 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Spatial PHP tools. The WfsLayer class helps create requests on a WFS layer using a PHP object. Web Feature Service (WFS) is a standard of the Open Geospatial Consortium.
Read-model components for Daikon-CQRS projects.
Agnostic model to efficiently query and scroll any kind of data (SQL, Search engine, HTTP API, CSV, ...) and push them anywhere with a ETL
Elasticsearch7 adapter for Daikon-CQRS projects.
Declarative, PostgreSQL-native management of materialized views: define views as versioned SQL, synchronise, rebuild, refresh (concurrently) and read them safely. Runs on Doctrine DBAL or a bare PDO connection.
Makes a json schema instance for the transmitted values and schema
统计信息
- 总下载量: 53
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 18
- 依赖项目数: 2
- 推荐数: 0
其他信息
- 授权协议: GPL-3.0-only
- 更新时间: 2022-03-27