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
> --
>
> You received this message because you are subscribed to the Google Groups "DataMapper" group.
> To post to this group, send email to
datam...@googlegroups.com.
> To unsubscribe from this group, send email to
datamapper+...@googlegroups.com.
> For more options, visit this group at
http://groups.google.com/group/datamapper?hl=en.
>
>
>