I also use a master/slave connection in my project and IMO there is no 
generic approach for this problem. Each action must be considered critical 
(master) or not (slave) by admitting for none critical action we can 
sometimes have wrong data due to replication lag or others problems.

In symfony2 i have implemented the following thing to easily choose the 
specific connection for my controllers action

I have 
 - 2 DBAL and 2 EntityManager : master and slave with master by default (So 
you can inject the correct dbal or entitymanager to use for your services)
 - An abstract class : ConnectionController
 - An annotation : Connection
 - A controller listener fired on kernel.controller event : 
ConnectionControllerListener
 
When my controller is an instance of ConnectionController i look at the 
Connection annotation in the action method to choose which EntityManager to 
inject to my controller and if there is no annotation i inject 
default EntityManager.

regardes,
Joël





-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony developers" group.
To post to this group, send email to symfony-devs@googlegroups.com
To unsubscribe from this group, send email to
symfony-devs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/symfony-devs?hl=en

Reply via email to