You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by Suraj Kumar <su...@inmobi.com> on 2014/05/13 14:29:39 UTC

Are these in Plugin scope?

[cross-posted]

Hi,

We have hacked couchdb erlang code to make it do some low-level things we
wanted for our system. The changes are:

1. Audit keeping: set a mandatory (potentially configurable) field in each
doc with the UserCtx.name and Date/Time. (like, "last_modified_time" =
current_time and "last_modified_by" = UserCtx.name).

2. Audit trail: whenever docs are created/updated, also write another
"snapshot" doc for history keeping.

>From what I understand, plugins work at the HTTP layer only and not at the
DB layer. Am I right? It appears like a way to introduce new API end-points
than to affect behaviour of existing (core) APIs.

We don't want to intercept every write API call (PUT, POST, various update
handler functions, etc.,). Nor do we want to tell clients to do the ugly
thing of "duplicating the very information  in the doc which they provide
at HTTP layer" (ie., HTTP basic auth).

Are these two features in Plugin scope? If not, what is the "right" way of
doing this? (Two options I see: 1. introduce a middle ware layer 2.
continue to hack couchdb-erlang code and maintain it ourselves*). Any other
options?

Cheers,

  -Suraj

* It seems to me, option #2 is still *cheaper* than inventing a "highly
available and scalable middle ware layer".


-- 
An Onion is the Onion skin and the Onion under the skin until the Onion
Skin without any Onion underneath.

-- 
_____________________________________________________________
The information contained in this communication is intended solely for the 
use of the individual or entity to whom it is addressed and others 
authorized to receive it. It may contain confidential or legally privileged 
information. If you are not the intended recipient you are hereby notified 
that any disclosure, copying, distribution or taking any action in reliance 
on the contents of this information is strictly prohibited and may be 
unlawful. If you have received this communication in error, please notify 
us immediately by responding to this email and then delete it from your 
system. The firm is neither liable for the proper and complete transmission 
of the information contained in this communication nor for any delay in its 
receipt.

Re: Are these in Plugin scope?

Posted by Aurélien Bénel <au...@utt.fr>.
>> 2. Audit trail: whenever docs are created/updated, also write another
>> "snapshot" doc for history keeping.
> can the list confirm these statements :
> 2. cannot because it requires the creation of an extra doc (since couchdb revisions can not be considered for history keeping, one of the reason is that they don't survive replication)


What could be done with an update handler is keeping the history of data in the document itself (in a special attribute).


Regards,

Aurélien 


Re: Are these in Plugin scope?

Posted by Franck Eyraud <fr...@nospam.yrnm.net>.
Le 13/05/2014 22:30, Aurélien Bénel a écrit :
> Hi Suraj,
>
>> 1. Audit keeping: set a mandatory (potentially configurable) field in each
>> doc with the UserCtx.name and Date/Time. (like, "last_modified_time" =
>> current_time and "last_modified_by" = UserCtx.name).
>> 2. Audit trail: whenever docs are created/updated, also write another
>> "snapshot" doc for history keeping.
> I might have misunderstood what you wanted to achieve but couldn't you do that with a simple update handler?
Interesting question; can the list confirm these statements :

1. can be done with a simple update handler
2. cannot because it requires the creation of an extra doc (since 
couchdb revisions can not be considered for history keeping, one of the 
reason is that they don't survive replication)

This plugin subject seems very interesting to me, but it is 
unfortunately not very discussed in the mailing list.

Le 13/05/2014 14:29, Suraj Kumar a écrit :
>  From what I understand, plugins work at the HTTP layer only and not at the
> DB layer.
It is almost true, except that you can also plug in in the 
authentication layer.
I suppose that allowing the plugins to intervene at the dB layer would 
complicate much the db engine as trust would not be the same; but the 
plugin system is currently quite new, and might evolve.

> Are these two features in Plugin scope?
Currently from what I know (but I'm a mere user that looked as you did), 
yes they are out of scope.

> If not, what is the "right" way of
> doing this? (Two options I see: 1. introduce a middle ware layer 2.
> continue to hack couchdb-erlang code and maintain it ourselves*). Any other
> options?
One another solution might be some extra services listening for changes 
(in node.js for example), and making the desired modifications.

Franck



Re: Are these in Plugin scope?

Posted by Aurélien Bénel <au...@utt.fr>.
Hi Suraj,

> 1. Audit keeping: set a mandatory (potentially configurable) field in each
> doc with the UserCtx.name and Date/Time. (like, "last_modified_time" =
> current_time and "last_modified_by" = UserCtx.name).
> 2. Audit trail: whenever docs are created/updated, also write another
> "snapshot" doc for history keeping.

I might have misunderstood what you wanted to achieve but couldn't you do that with a simple update handler?


Regards,

Aurélien