I definitely want to use this in the near future for a basic sharding
setup. The idea is very basic, I would just wrap each request in a
repository block to select the correct shard where the data is
available.

Determining which shard to select can also include querying for
certain objects. Basically something like the following in a really
simplified version, but it does bring across the point I think. What
it does is a simple sharding algorithm based on odd / even id's. In
real life I would use something like "the first 100 customers are in
shard 1", "second 100 in shard 2" etc. A default repository would
contain the actual customers and data that needs to be available over
all customers.

I think it's perfectly fine to have only one active repository at one
time, so if I would want to access the default repository again inside
the request, I would need to force that.

repository(:default) do
  resource = SomeModel.get(id)
  resource_repository = "resource_repo_#{resource.id % 2}".to_sym
  repository(resource_repository) do
    view_resources = OtherModel.all
  end
end

If you want, I can write out the architecture more elaborately.

-- 
Regards,

Dirkjan Bussink

On Tue, Dec 8, 2009 at 10:51, MarkMT <[email protected]> wrote:
> I definitely use this feature. I use it for synching model data
> between two different machines.
>
> Mark.
>
> Dan Kubb (dkubb) wrote:
>> Hi,
>>
>> I was wondering how many people use the same model with different
>> repositories?
>>
>> I know many people (myself included) use the same model with a
>> different repository for testing as opposed to development, but that's
>> not really what I mean.  I mean do you persist/retrieve data from a
>> specific model using multiple repositories within the same context?
>>
>> A good way to know if this applies to you is to ask yourself "Do I
>> have code that wraps finders or persistence methods in repository()
>> blocks?".
>>
>> I'm just trying to get a handle on how people use DM "in the wild" and
>> make sure that the features DM provides are closer inline with
>> people's use cases, and gradually move away from approaches that
>> aren't being used at all yet clutter up the code to support.  If I had
>> to guess I'd say that the ability for a single model to be accessible
>> by multiple repositories all at the *same time* is seldom -- if at all
>> -- used.
>>
>> --
>>
>> Thanks,
>>
>> Dan
>> (dkubb)
>
> --
>
> 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.
>
>
>

--

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.


Reply via email to