aescarcha / async
一个用于处理Symfony实体序列化和反序列化的工具包,它是Symfony序列化组件的层
dev-master
2016-08-03 16:55 UTC
Requires
- php: >=5.5.9
- doctrine/doctrine-bundle: ~1.4
- doctrine/orm: ^2.4.8
- oldsound/rabbitmq-bundle: 1.*
- symfony/dependency-injection: ~2.3 || ~3.0
Requires (Dev)
- phpunit/phpunit: ~4.8|~5.0
- symfony/phpunit-bridge: ~2.7
This package is auto-updated.
Last update: 2024-09-19 10:44:38 UTC
README
简介
此工具包处理Symfony实体的事件,如持久化、删除等。它将任务推送到RMQ,以便以异步方式处理重任务。
安装
composer require aescarcha/async
配置
在您的config.yml中配置RMQ,例如:
old_sound_rabbit_mq:
connections:
default:
host: 'localhost'
port: 5672
user: 'guest'
password: 'guest'
vhost: '/'
lazy: false
connection_timeout: 3
read_write_timeout: 3
# requires php-amqplib v2.4.1+ and PHP5.4+
keepalive: false
# requires php-amqplib v2.4.1+
heartbeat: 0
producers: #the process sending messages to the broker is called producer
async_refresher:
connection: default
exchange_options: {name: 'async-refresher', type: direct}
consumers: #the process receiving those messages is called consumer
async_refresher:
connection: default
exchange_options: {name: 'async-refresher', type: direct}
queue_options: {name: 'async-refresher'}
callback: aescarcha.persist_listener
services.yml
#Listener to trigger async regeneration, this service is also a rabbit consumer
aescarcha.persist_listener:
class: Aescarcha\ChallengeBundle\Listener\PersistListener
arguments: [ @service_container ]
tags:
- { name: doctrine.event_listener, event: postPersist }
- { name: doctrine.event_listener, event: postUpdate }
- { name: doctrine.event_listener, event: postRemove }
- { name: doctrine.event_listener, event: postSoftDelete }
AppKernel.php
$bundles = array(
new Aescarcha\SerializerBundle\AescarchaSerializerBundle(),
);
测试
测试在仓库中提供,但它们不起作用,因为测试需要一些实体和仓库来运行,使它们在干净的symfony安装中运行也是一个待办事项
SERIUS TODO
在监听器上调用动态类,将这些类移出仓库