pixelfederation/doctrine-resettable-em-bundle 问题修复 & 功能扩展

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

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

pixelfederation/doctrine-resettable-em-bundle

Composer 安装命令:

composer require pixelfederation/doctrine-resettable-em-bundle

包简介

Symfony bundle for decorating default entity managers using a resettable decorator.

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 pixelfederation/doctrine-resettable-em-bundle

SETUP

// config/bundles.php
return [
    //...
    \PixelFederation\DoctrineResettableEmBundle\PixelFederationDoctrineResettableEmBundle::class => ['all' => true]
    //...
];
pixel_federation_doctrine_resettable_em:
  exclude_from_processing:
    # these entity managers won't be wrapped by the resettable entity manager:
    entity_managers:
        - readonly
    connections:
        # 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

If you have php-fpm you need only handle RedisCluster on message queue consuming. So you need to disable Initializers and disable processing for all dbal connections.

pixel_federation_doctrine_resettable_em:
  disable_request_initializers: true
  exclude_from_processing:
      connections:
          dbal:
            - default
            - definition

To enable ping on entity managers during message queue consuming, you can add doctrine_ping_connection middleware: https://symfony.com/doc/current/messenger.html#middleware-for-doctrine

pixelfederation/doctrine-resettable-em-bundle 适用场景与选型建议

pixelfederation/doctrine-resettable-em-bundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 119.1k 次下载、GitHub Stars 达 20, 最近一次更新时间为 2019 年 11 月 08 日, 在 PHP 生态内属于活跃度较高的组件。

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

围绕 pixelfederation/doctrine-resettable-em-bundle 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 119.1k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 20
  • 点击次数: 23
  • 依赖项目数: 2
  • 推荐数: 12

GitHub 信息

  • Stars: 20
  • Watchers: 3
  • Forks: 7
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-11-08