Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Multi-tenant application with Salat
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  2 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Manuel Bernhardt  
View profile  
 More options Jul 13 2012, 12:17 pm
From: Manuel Bernhardt <bernhardt.man...@gmail.com>
Date: Fri, 13 Jul 2012 18:17:12 +0200
Local: Fri, Jul 13 2012 12:17 pm
Subject: Multi-tenant application with Salat
Hi,

I'm looking into making our Play 2 application multi-tenant, in such a
way that it would use different connections (to different DBs)
depending on which subdomain / URL is accessed (customer1.foo.org,
customer2.foo.org, ...).

We've been using SalatDAO so far, and I see there's now also a
ModelCompanion trait that adds additional functionality.

I've been trying to think of an easy way to keep the straight-forward
way of accessing the DAO companion object directly ( e.g.
User.find(...) ) and yet switch to the correct connection behind the
scenes.

What I've been thinking about is to make use of implicit parameters, like e.g.

case class User(...)

object User extends ModelCompanion[User, ObjectId] {

  def dao(implicit subdomain: String) = { ... }

  def findAll()(implicit subdomain: String) = dao.find(MongoDBObject())

}

subdomain could be anything really, the crux is that if it is in
scope, when a method of the User DAO is called, it'd be able to pass
that key along and dao could resolve dynamically to whatever is
suited.

Does anyone think this kind of design is a good idea, and is there
perhaps something more clever (right now you've got to include that
implicit parameter all over, but I can't think of a better way atm)?

I've been thinking of giving this a go by implementing a delegating
DAO trait that'd be used in all cases. Note that I'd probably use that
directly instead of using the ModelCompanion (we're not using it,
since we don't need the JSON capabilities).

Thanks,

Manuel


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Manuel Bernhardt  
View profile  
 More options Oct 29 2012, 9:39 am
From: Manuel Bernhardt <bernhardt.man...@gmail.com>
Date: Mon, 29 Oct 2012 14:38:58 +0100
Local: Mon, Oct 29 2012 9:38 am
Subject: Re: Multi-tenant application with Salat
Hi,

for the record, this is the solution I went for in the end:

https://github.com/delving/culture-hub/blob/12.10/web-core/app/models...

One example implementation:

- case class definition:
https://github.com/delving/culture-hub/blob/12.10/web-core/app/models...
- MultiModel: https://github.com/delving/culture-hub/blob/12.10/web-core/app/models...
- DAO implementation:
https://github.com/delving/culture-hub/blob/12.10/web-core/app/models...
(the BindingModel / Injectable are just related to using Subcut, not
to the MultiModel per-se)

Manuel

On Fri, Jul 13, 2012 at 6:17 PM, Manuel Bernhardt


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »