承接 matthiasnoback/tail-event-stream 相关项目开发

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

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

matthiasnoback/tail-event-stream

Composer 安装命令:

composer require matthiasnoback/tail-event-stream

包简介

A simple, tail-based event stream

README 文档

README

An event stream library based on tail.

Note: I don't think you should use this library in a real project, but it's great for educational purposes. I use it in workshops only."

Getting started

Install using Composer:

composer require matthiasnoback/tail-event-stream 

Usage

Adding messages to the stream:

use TailEventStream\Producer;

$streamFilePath = __DIR__ . '/var/stream.txt';

$producer = new Producer($streamFilePath);
$producer->produce('hello_world', ['Hello' => 'World!']);

The stream.txt file contains one message per line:

{"messageType":"hello_world","data":{"Hello":"World!"}}

Using tail -f a consumer can read each message from the stream, and it will keep consuming messages until you quit the process:

use TailEventStream\Consumer;

$streamFilePath = __DIR__ . '/var/stream.txt';

$consumer = new Consumer($streamFilePath);

$consumer->consume(function (string $messageType, array $data) {
    // $messageType will be 'hello_world'
    // $data will  be ['Hello' => 'World!']
});

consume() accepts a second argument, which is the index (or line) at which to start.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-01-25

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固