On May 8, 9:42 am, Jeremy Evans <[email protected]> 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 decided to find out myself, and it looks like I was right, see
below.

> > Two entry points for specifying connection are sufficient for me: one
> > factory method (that creates model instances) and method for selecting
> > objects (find).
>
> > Something like:
> > schedule = ETLJobSchedule.new_from_connection(@connection)
> > schedules = ETLJobSchedule.find_using_connection(@connection, ...)
>
> That's not how Sequel works.  You don't deal with connection objects,
> and while Sequel does make them available if you need them for low
> level stuff, there's no Sequel methods that accept them as arguments.
> You can do something like:
>
>   schedules = ETLJobSchedule.server(:shard_id).first(...)
>
> To retrieve schedules from a specific shard.
>
> However, the new_from_connection can't be duplicated without some
> small extensions.  Currently you'd need to override Model#_insert
> (kind of large), but I'd be OK with refactoring so that you'd only
> need to override a new method like _insert_dataset.  For updating and
> deleting records, you would have to override _update_dataset and
> _delete_dataset.  The only issue there is that Sequel does not store
> which shard was used to retrieve the objects.  For that you could use
> the tactical_eager_loading plugin, and call retrieved_by to get access
> to the dataset that was used to retrieve the object, and get the shard
> id to use in _update_dataset and _delete_dataset.

Try the patch at http://pastie.org/951880.txt combined with the plugin
at http://pastie.org/951879.txt.

I did some basic testing and it appears to work.  I'll be adding
documentation and specs, but you can expect this plugin to be
committed to Sequel before the next release.

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