pmg/pheanstalk-bundle

一个简单的集成Pheanstalk与Symfony的包

v5.0.0 2024-01-26 16:02 UTC

This package is auto-updated.

Last update: 2024-09-18 22:05:53 UTC


README

一个极其简单的Symfony包,将一个或多个Pheanstalk连接放入您的Symfony应用程序中。

如果您正在寻找功能更全的包,请查看LeezyPheanstalkBundle

安装

1. 下载包

composer require pmg/pheanstalk-bundle

2. 启用包

<?php
// app/AppKernel

class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = [
            // ...
            new PMG\PheanstalkBundle\PmgPheanstalkBundle(),
        ];

        // ...

        return $bundles;
    }

    // ...
}

配置

默认情况下,包会在容器中提供名为pmg_pheanstalk的一个Pheanstalk\Pheanstalk实例。它连接到默认的localhost主机和11300端口。

单个连接示例

# Default configuration for "PmgPheanstalkBundle"
pmg_pheanstalk:
    # The connection's host.
    host:                 localhost

    # The connection's port.
    port:                 11300

    # The connection's timeout.
    timeout:              null

    # Whether or not to keep the connection's socket around between requests. See https://php.ac.cn/manual/en/function.pfsockopen.php
    persist:              false

多个连接

# Default configuration for "PmgPheanstalkBundle"
pmg_pheanstalk:
    # The default connection that will be made available at the `pmg_pheanstalk` service
    default_connection:   default
    connections:
        # use the default configuration
        default: ~

        # another connection, will be put at the `pmg_pheanstalk.another` service
        another:
            host: anotherServier.com
            port: 11301

统计端点

此包包含一些基本的端点,返回有关队列管道的JSON数据。每个端点还允许提供connection参数。如果没有提供,则使用默认连接。

启用端点

将以下行添加到您的routing.xml文件中。(或等效的YML文件)

   <import resource="@PmgPheanstalkBundle/Resources/config/routing.yml">
        <default key="_format">json</default>
   </import>

可用端点

  • [GET] /{tube} - 提供关于给定管道的beanstalkd所有信息
  • [GET] / - 提供关于beanstalkd中所有管道的所有信息