定制 justblackbird/amphp-priority-emitter 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

justblackbird/amphp-priority-emitter

Composer 安装命令:

composer require justblackbird/amphp-priority-emitter

包简介

In-memory implementation of async emitter with prioritized messages

README 文档

README

Latest Stable Version Test

In-memory implementation of async emitter with prioritized messages

Why

Implementation of AMP Emitter is backed by a queue. It covers many cases but sometimes a priority queue is needed.

For example, you're building a bot for a social network or a messenger. Assume that the bot can react for users' commands and broadcast information to all its subscribers. These two types of messages have different priorities. Commands' responses must be sent as soon as possible to keep UX responsive but broadcasting messages can wait for a while.

You can build the app around a message bus. There is some code that pushes messages to the bus, and some code that pull them out and transfer to social network API.

You cannot use Emitter shipped with AMP because in such case broadcasting messages will block command ones because there is no way to set priority with AMP Emitter.

This library adds and Emitter with API similar to AMP Emitter but with priority support.

Installation

composer require justblackbird/amphp-priority-emitter

Usage

use Amp\Loop;
use JustBlackBird\AmpPriorityEmitter\Emitter;

// The following example will output:
// - important message
// - message one
// - message two

Loop::run(static function() {
    $emitter = new Emitter();

    $emitter->emit('message one', 0);
    $emitter->emit('message two', 0);
    $emitter->emit('important message', 5);
    $emitter->complete();

    $iterator = $emitter->iterate();
    while(yield $iterator->advance()) {
        echo "- " . $iterator->getCurrent() . "\n";        
    }
});

License

MIT (c) Dmitry Simushev

The implementation is based on AMP Emitter.

统计信息

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

GitHub 信息

  • Stars: 2
  • Watchers: 1
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-07-25

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固