On Sep 30, 9:17 am, Luke Galea <[email protected]> wrote:
> Hi all,
>
> Has anyone found a way to make datamapper split reads and writes to
> different servers (ie: reads against a slave, writes against the
> master??)
>
> Thanks in advance!
You could try writing a read/write adapter. You might start with
something like this:
require 'forwardable'
module DataMapper::Adapters
class ReadWriteAdapter < AbstractAdapter
extend Forwardable
def_delegators :@read, :read
def_delegators :@write, :create, :update, :delete
private
def initialize(name, options)
super(name, options)
assert_kind_of 'options', @options[:write], Hash
assert_kind_of 'options', @options[:read], Hash
@write = ::DataMapper.setup("#{name}_write".intern, @options
[:write])
@read = ::DataMapper.setup("#{name}_read".intern, @options
[:read] )
end
end
end
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"DataMapper" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/datamapper?hl=en
-~----------~----~----~----~------~----~------~--~---