flux-eco / global-stream
存储跨域事件并将它们发布给已订阅的消费者
1.0.1
2022-04-15 20:43 UTC
Requires
- php: >=8.0
- ext-curl: *
- ext-json: *
- ext-yaml: *
- flux-eco/json-schema-document: >=1.0.0
- flux-eco/projection: >=1.0.0
- flux-eco/storage: >=1.0.0
- flux-eco/value-object: >=1.0.0
README
存储跨域事件并将它们发布给已订阅的消费者。目前处于开发初期阶段,主要用于展示全局流的用法。对于大型系统,Apache Kafka 或类似系统更合适。
以下示例应用程序演示了用法: https://github.com/flux-caps/todo-app
用法
.env
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=../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
example.php
<?php
require_once __DIR__ . '/../vendor/autoload.php';
FluxEco\DotEnv\Api::new()->load(__DIR__);
//initialize
fluxGlobalStream\initialize();
//publish state change
$correlationId = fluxValueObject\getNewUuid();
$createdBy = 'example@fluxlabs.ch';
$subject = 'AggregateRoot';
$subjectId = fluxValueObject\getNewUuid();
$subjectSequence = 1;
$subjectName = 'account';
$jsonObjectSchema = json_encode(yaml_parse(file_get_contents('schemas/domain/account.yaml')));
$eventName = 'aggregateRootCreated';
$currentState = json_encode([
"firstname" => [
"value" => "Emmett",
"isEntityId" => false
],
"lastname" => [
"value" => "Brown",
"isEntityId" => false
]
]);
fluxGlobalStream\publishStateChange(
$correlationId,
$createdBy,
$subject,
$subjectId,
$subjectSequence,
$subjectName,
$jsonObjectSchema,
$eventName,
$currentState
);
//republish all states
fluxGlobalStream\republishAllStates(
[$subjectName]
);
贡献 💜
请...
- ... 在 https://git.fluxlabs.ch 注册账户
- ... 创建 pull requests 🔥
调整建议 / 错误报告 🐾
请...
- ... 在 https://git.fluxlabs.ch 注册账户
- ... 向我们请求服务等级协议: support@fluxlabs.ch 😘
- ... 阅读并创建问题