定制 swoole-bundle/resetter-bundle 二次开发

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

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

swoole-bundle/resetter-bundle

最新稳定版本:1.1.1

Composer 安装命令:

composer require swoole-bundle/resetter-bundle

包简介

Symfony bundle with resetters for various connections, e.g. doctrine/dbal and phpredis.

README 文档

README

This bundle should be used with workloads where Symfony doesn't get initialized on each request, but stays in memory and the same instance handles multiple requests, one after another (e.g. when using Swoole Bundle). Another use case would be message queue consuming (e.g. Symfony messenger), where it is needed to clear (and possibly reset) the entity manager after processing a message.

The best feature of this bundle is, that it wraps all configured entity managers into a ResettableEntityManager instance, which is able to reset the entity manager when it gets stuck on an exception. After each request the entity manager gets cleared or reset, if an exception occurred during request handling.

Also another feature is, that on each request start the entity manager connection gets pinged, so the connection won't get closed after some period of time.

Instalation

composer require swoole-bundle/resetter-bundle

SETUP

// config/bundles.php
return [
    //...
    \SwooleBundle\ResetterBundle\SwooleBundleResetterBundle::class => ['all' => true]
    //...
];
swoole_bundle_resetter:
  exclude_from_processing:
    # these entity managers won't be wrapped by the resettable entity manager:
    entity_managers:
        - readonly
    # these dbal connections won't be assigned to the keep alive handler
    dbal:
      - readonly
    # these redis cluster connections won't be assigned to the keep alive handler
    redis_cluster:
        - default
  # default 0 - if set, the connection ping operation will be executed each X seconds 
  # (instead of at the beginning of each request) 
  ping_interval: 10 
  # default false - if set to true, the app will check if there is an active transaction
  # in the processed connection, and it will rollback the transaction
  check_active_transactions: true
  # for reader writer connections, each has to be defined as 'reader' or 'writer' to be able for the symfony
  # app to reconnect after db failover. currently only AWS Aurora is supported.
  failover_connections:  
    default: writer
  # redis clusters which need to be failed over should be registered here
  # it's really important to set default timeouts to a low value, e.g. 2 seconds, so the app won't block for too long
  redis_cluster_connections:
    default: 'RedisCluster' # connection name (can be literally anything) => redis cluster service id

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-02-01