fukamachi / integral

[OBSOLETE] Use Mito instead.
https://github.com/fukamachi/mito
BSD 3-Clause "New" or "Revised" License
54 stars 3 forks source link

handle read replica #6

Closed rudolph-miller closed 9 years ago

rudolph-miller commented 9 years ago

connect-top-level and get-connection can handle only one connection. I want to meke these more customizable. any idea?

One way is to make get-connection customizable to take :select or other keyword, and give :select in find-dao.

fukamachi commented 9 years ago

It can be done like datafly does. (datafly is my newer project and it may have better interfaces) I'll think about it later.

fukamachi commented 9 years ago

Hm, I just got why did you get to #9.

However, I'm not willing to add such a specific feature for DB sharding.

Why don't you define an :around method for select-dao like this?

(defmethod select-dao :around ((class <dao-table-class>) &rest expressions)
  (let ((*db* *read-db-connection*))
    (call-next-method)))
rudolph-miller commented 9 years ago

I see, it's method. That's useful solution.

fukamachi commented 9 years ago

Okay, I'm gonna make some changes for it, like exporting make-connection and *db*. :+1:

rudolph-miller commented 9 years ago

and please make make-connection more easily.

rudolph-miller commented 9 years ago

API should be like (connect-toplivel :mysql :database-name "sample" user: "sample-user")

fukamachi commented 9 years ago

Sure. I saw what you've done at #9 and it looks nicer. :grin:

rudolph-miller commented 9 years ago

thx :smile:

rudolph-miller commented 9 years ago

LGTM without the doc of (defvar *db* nil "Current connection object.Don't use from other packages.") and I could handle read-replica with (defmethod retrieve-by-sql :around).

rudolph-miller commented 9 years ago

thx :)