swoole-bundle/resetter-bundle 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

swoole-bundle/resetter-bundle

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

Optional: Doctrine ORM

doctrine/orm is not a hard requirement. Install it only if you also want the entity managers to be wrapped in a ResettableEntityManager (cleared/reset between requests):

composer require doctrine/orm

When ORM is absent, the entity-manager decoration is skipped automatically.

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

swoole-bundle/resetter-bundle 适用场景与选型建议

swoole-bundle/resetter-bundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 19.08k 次下载、GitHub Stars 达 3, 最近一次更新时间为 2025 年 02 月 01 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 swoole-bundle/resetter-bundle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 swoole-bundle/resetter-bundle 我们能提供哪些服务?
定制开发 / 二次开发

基于 swoole-bundle/resetter-bundle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

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