承接 daison/laravel-horizon-cluster 相关项目开发

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

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

daison/laravel-horizon-cluster

最新稳定版本:0.4.0

Composer 安装命令:

composer require daison/laravel-horizon-cluster

包简介

A modified laravel/horizon with cluster support

README 文档

README

Packagist Downloads

seeking's laravel horizon

Laravel Horizon - Cluster Support

This package extends Laravel Horizon with support for a Redis cluster. Based on my testing, it should also be compatible with AWS Elastic Load Balancer.

Installation

composer require daison/laravel-horizon-cluster

After installing this package, now publish the assets using horizon:install

php artisan horizon:install

Remove the auto discover

Modify your original laravel's composer.json and add this

{
    "extra": {
        "laravel": {
            "dont-discover": [
                "laravel/horizon"
            ]
        }
    }
}

Use the modified horizon

Modify your config/app.php

return [
    'providers' => [
        // ...

        Daison\LaravelHorizonCluster\AppServiceProvider::class,
        App\Providers\HorizonServiceProvider::class,
    ],
];

config/database.php

Usually your laravel config/database.php should look like this.

return [
    'redis' => [
        'client' => 'predis',

        'clusters' => [
            'default' => [
                [
                    'host'     => env('REDIS_HOST', '127.0.0.1'),
                    'port'     => env('REDIS_PORT', '6379'),
                    'password' => env('REDIS_PASSWORD', null),
                    'database' => 0,
                ],
            ],
            // ...
        ],

        'options' => [
            'cluster' => 'redis',
        ],
    ],
];

config/horizon.php

Make sure your horizon will have this kind of config or similar.

return [
    'use' => 'clusters.default',

    // ...

    'defaults' => [
        'worker' => [
            'connection' => 'redis',
            'balance'    => env('HORIZON_QUEUE_WORKER_BALANCE', false),
            'timeout'    => env('HORIZON_QUEUE_WORKER_TIMEOUT', 10),
            'sleep'      => env('HORIZON_QUEUE_WORKER_SLEEP', 3),
            'maxTries'   => env('HORIZON_QUEUE_WORKER_MAXTRIES', 3),
        ],
    ],

    'environments' => [
        env('APP_ENV') => [
            'worker' => [
                'connection' => 'redis',
                'queue'      => [
                    '{redis-high}',
                    '{redis}',
                    '{redis-low}',
                ],
                'memory'       => env('HORIZON_QUEUE_WORKER_MEMORY', 128),
                'minProcesses' => env('HORIZON_QUEUE_WORKER_MIN_PROCESSES', 1),
                'maxProcesses' => env('HORIZON_QUEUE_WORKER_MAX_PROCESSES', 3),
            ],
        ],
    ],
];

config/queue.php

Make sure your 'redis' is wrapped with curly brace

// ...

'redis-low' => [
    // ...
    'queue' => env('REDIS_QUEUE', '{redis-low}'),
    // ...
],

'redis' => [
    // ...
    'queue' => env('REDIS_QUEUE', '{redis}'),
    // ...
],

'redis-high' => [
    // ...
    'queue' => env('REDIS_QUEUE', '{redis-high}'),
    // ...
],

Enjoy using Laravel Horizon with Cluster support!

统计信息

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

GitHub 信息

  • Stars: 15
  • Watchers: 2
  • Forks: 9
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-10-11