[Backgroundrb-devel] multiple database design question

hemant gethemant at gmail.com
Thu Aug 14 23:13:26 EDT 2008


On Fri, Aug 15, 2008 at 12:32 AM, Woody Peterson
<woody at crystalcommerce.com> wrote:
> Hi all. I have a few questions, but I'll start a thread per question. My
> first is a design issue that's fairly specific to my application, but I
> thought someone might be willing to give out some insights.
>
> My application has multiple databases, one per client, and I hijack the
> database connection at the beginning of a request and connect it to the
> appropriate database. So, I have to pass the database to any workers so that
> they know which database to operate on. I have two choices here:
>
> 1) Have a single worker, pass in the database to all worker methods, and
> have the method connect to the correct database before beginning the real
> processing
>
> 2) Create multiple workers, one per database, and have them connect to the
> appropriate database when initialized via the 'create' method. Rails can
> then call methods on the appropriate database specific worker. without
> having to pass the database in to each method, although it will have to use
> the database as a worker key when getting the correct worker.
>
> I like the organization of the second method, but the simplicity of the
> first. I'm thinking I'll go with the first. Any thoughts?

Second version, certainly looks cleaner, besides, I wouldn't know, how
will you be passing db connections to worker.


More information about the Backgroundrb-devel mailing list