-
Notifications
You must be signed in to change notification settings - Fork 28
COUCHDB-769: Store attachments in the external storage. #82
base: master
Are you sure you want to change the base?
Conversation
…mplementation, supports OpenStack Swift and SoftLayer Object store
@@ -407,7 +407,15 @@ db_req(#httpd{method='POST',path_parts=[_,<<"_bulk_docs">>], user_ctx=Ctx}=Req, | |||
true -> [all_or_nothing|Options]; | |||
_ -> Options | |||
end, | |||
case fabric:update_docs(Db, Docs, Options2) of | |||
couch_log:debug("chttpd_db: update_docs wellcome. Going to store attachment in external store",[]), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
welcome! (:
Please fix:
|
Would be nice to see some tests for this to prove that this all works. |
NewNewDoc = fabric_attachments_handler:inline_att_store(Db, NewDoc); %store_single_document | ||
"false" -> | ||
couch_log:debug("Store inline attachmets in Swift disabled",[]), | ||
NewNewDoc = NewDoc |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better not assign variable in case, but assign case result to variable.
Is it possible to decouple logic of working with external attachments from the logic that works with internal ones? Mixing them makes quite hard to follow the track. |
@kxepal : you asked to "Is it possible to decouple logic of working with external attachments from the logic that works with internal ones? Mixing them makes quite hard to follow the track." Can you please explain me what would you like to see exactly? Perhaps i didn't understand it. |
@gilv I mean to get rid all |
@kxepal @rnewson
|
Given the nature of the patch, this cannot merge without tests, assuming all style and other issues are resolved. |
false -> | ||
couch_log:debug("externalize attachment: disabled",[]), | ||
NewDocs = Docs | ||
end, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be cleaner if the result of the case statement was assigned to NewDocs
. i.e, NewDocs = case...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hm, and really, it should be fabric:update_docs
itself that makes this decision, the http presentation layer should not know.
summary: there's too much logic in the http layer, fabric should be the place where the decisions are made. |
@kxepal I need your advice on the following:
The relevant code in "chttpd_db" is: ExtStoreID = couch_att:fetch(att_extstore_id,TmpAtt), My question is: what is the best way to handle this? case fabric_att_handler:att_get(Db, TmpAtt), |
@gilv It's not a bad request since it's not a user fault that Swift is down. HTTP 503 or HTTP 502 looks good here. But yes, the only thing you can do is to fail and throw error back. Btw, what's the timeout you use for fetching remote attachments? Do you stream response from Swift or buffer it in memory before return back to user? |
@kxepal @rnewson
|
@kxepal Can you please review the recent code? |
Initial implementation that allows CouchDB to store attachments outside of the database file.
This implementation supports OpenStack Swift and SoftLayer Object store