On May 8, 11:46 am, Gary Doades <[email protected]> wrote:
> On 08/05/2010 5:42 PM, Jeremy Evans wrote:> However, sharding is more of a 
> dataset feature, and while models have
> > full support for sharding when retrieving records, there isn't any
> > built in support for saving records to specific shards.  It's probably
> > not hard to add if you need it, though.
>
> I just picked up on this section of your reply. At the moment we assign
> a shard_id to a model:
>
> class Client < Sequel::Model(:client)
> end
> # get the model to use the "current" shard
> Client.dataset.server!(:current)
>
> The current (default) shard is connected to a template database to
> initialize all the models. This is done just once at program start.
>
> We then switch databases at runtime by connecting the "current" shard  
> to a different database and use all the models. This *seems* to work
> just fine for retrieving and saving to the current shard. Is there
> something that won't work in this case that I might get bitten by?

It's not thread safe.  The correct way would be to set the shard to
use manually on each dataset.  However, depending on how your code is
structured, that may be a lot of work.

It's possible you'll run into issues, though I can't think of any
right now.  If thread safety isn't important, it may be a valid
approach.

Jeremy

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" 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/sequel-talk?hl=en.

Reply via email to