>
>From: Bill Moseley <[email protected]>
>To: DBIx::Class user and developer list <[email protected]>
>Sent: Tue, January 5, 2010 11:49:37 AM
>Subject: Re: [Dbix-class] DBIx::Class::Storage::Replication -- stick to master
>flag
>
>
>
>
>On Tue, Jan 5, 2010 at 6:22 AM, John Napiorkowski <[email protected]> wrote:
>
>>>
>>
>>
>>
>>Take a look at DBIx::Class::Schema::RestrictWithObject since I think that was
>>written to help with these kinds of trouble, might help. --john
>>
>
>Thanks John. I'm not clear how that might apply in this case. I need to hook
>into DBIx::Class::Storage::Replicated to determine when it selects the master
>vs. the slaves.
>
>I've looked at RestrictWithObject before and I can see at some level how it
>would be helpful to enforce a criteria on a search, but calling methods on the
>objects seems cleaner to me (or use search_related) so never looked that
>closely at it. Maybe it does more than I thought.
>
There's a few ways to force master read/write mode. For example, anything
inside a transaction will automatically send read traffic to the master. For
me I find that's enough for nearly all the master read use cases. You can
always add a 'flag' as well:
my $row = $resultset->search(undef, {force_pool=>'master'})->find($pk);
That's what I was thinking regarding ::RestrictedWithObject, although might
feel like a big hammer to you. You could
probably also add that to the default resultset attributes of a resultset
subclass
http://search.cpan.org/~frew/DBIx-Class-0.08115/lib/DBIx/Class/ResultSource.pm#resultset_attributes
Since you can put it into the result search attributes you could also do this
inside a resultset method. Let me know how it goes.
john
_______________________________________________
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/[email protected]