定制 acdphp/laravel-queued-events 二次开发

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

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

acdphp/laravel-queued-events

最新稳定版本:v2.1.0

Composer 安装命令:

composer require acdphp/laravel-queued-events

包简介

Dispatching Events into queues. This is especially useful for distributed systems events using fanout queues.

README 文档

README

Latest Stable Version

Dispatching Events into queues. This is especially useful for distributed systems events using fanout queues.

workflow

Installation

  1. Install the package
    composer require acdphp/laravel-queued-events

Usage

  1. Extend QueuedEvent to your event.

    use Acdphp\QueuedEvents\Events\QueuedEvent;
    
    class UserCreatedEvent extends QueuedEvent
    {
        // Remove the Dispatchable trait
    
        public function __construct(public $object)
        {
        }
    }
  2. Call dispatch()

    UserCreatedEvent::dispatch(['foo' => 'bar']);
    • You may specify a queue connection and queue:
    UserCreatedEvent::dispatch(['foo' => 'bar'])
        ->onConnection('your-fanout-queue-connection')
        ->onQueue('your-custom-queue');
    • Utilities are also available: dispatchIf(), dispatchUnless()
    // Dispatches if $condition is true
    UserCreatedEvent::dispatchIf($condition, ['foo' => 'bar']);
    
    // Dispatches if $condition is false
    UserCreatedEvent::dispatchUnless($condition, ['foo' => 'bar']);
  3. Default dispatch methods are prefixed with internal

    UserCreatedEvent::internalDispatch(['foo' => 'bar']);
    
    UserCreatedEvent::internalDispatchIf(['foo' => 'bar']);
    
    UserCreatedEvent::internalDispatchUnless(['foo' => 'bar']);

Configuration

php artisan vendor:publish --tag=queued-events-config

QUEUED_EVENTS_QUEUE_CONNECTION

The default queue connection will be whatever your QUEUE_CONNECTION is set. You may override this by setting QUEUED_EVENTS_QUEUE_CONNECTION

QUEUED_EVENTS_QUEUE

The default queue will be default. You may override this by setting QUEUED_EVENTS_QUEUE

Notes

  • Using Laravel helpers, like event(...) or app('events')->dispatch(...), will dispatch the job internally. Only use ::dispatch, ::dispatchIf and ::dispatchUnless to dispatch on queue.
  • Use Laravel's queued listener if you're only using this in a monolithic application.

License

The MIT License (MIT). Please see License File for more information.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-12-27