Grails: Use new Multiple Datasources for sharding?
I want to be able to put an object into one of several shards based on a value of a field. In milestone 2.0 I see examples like
def zipCode = ZipCode.auditing.get(42)
zipCode.auditing.save()
But how would I dynamically choose the data source. I want something more like
ZipCode.datasource(1).get(42) // where 1 is c开发者_如何学JAVAalculated based on some other value.
Is there anyway to do that?
See http://grails.org/plugin/sharding which uses the Datasources plugin. The new multiple-datasources support in Grails is the result of moving the Datasources plugin into core, so it should be straightforward to either update the plugin or borrow its code and adapt it.
精彩评论