承接 togos/phpipeable 相关项目开发

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

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

togos/phpipeable

Composer 安装命令:

composer require togos/phpipeable

包简介

A PHP framework for modeling data flows in a reactive-ish way, similar to Node streams

README 文档

README

Provides a lightweight framework for push-based stream processing.

$someDataSource = new SomethingThatImplementsPipeable();
$someDataSink = new SomethingThatImplementsSink();
$someDataSource->pipe($someDataSink);

// Our pipe system is now in place,
// so shove some data through:

$someDataSource->emitSomeStuff(); // Use imagination here
$results = $someDataSource->emitClose(); // Let everyone know that's all,
                                         // and collect feedback from sinks

Philosophical notes about the Sink interface

For reference:

interface TOGoS_PHPipeable_Sink
{
	function open(array $fileInfo=array());
	function item($item, array $metadata=array());
	function close(array $info=array());
	// __invoke(...) should be like item(...)
}

An alterntive approach would be to have an even simpler definition for the sink interface such as 'a 1-ary function'. Open and close events would be passed to the function using the same mechanism as data items (this is how EIT's logging framework is defined).

A disadvantage to that approach is that your data items then need to be wrapped in some kind of object to distinguish them from stream metadata, which adds complexity to the code that implements and uses the sink.

The more complex sink interface maps more nicely to the use cases that I'm concerned with today, which are importing and transforming CSV files. Breaking out open(...) item(...) and end(...) calls gives some guidance about the meaning of metadata and the order in which they should be called, freeing implementing classes from having to define those things.

close(...) marks a point at which to commit any changes and is a convenient way to get information from deeply nested sinks back to the caller.

统计信息

  • 总下载量: 36
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 5
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-02-09

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固