You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by Franck Eyraud <fr...@yrnm.net> on 2013/12/05 19:05:32 UTC

Re: Version 1.4 features: Plugin system

Hello,

I cross post this since it seems better to follow up on the developers 
mailing list.

I started to work from Jan's my-first-couchdb-plugin to adapt the LDAP 
feature from chao into a couchDB plugin.
https://github.com/franck-eyraud/ldap-auth-couchdb-plugin

Up to now, I managed to do it, by adding an auth handler.

But in order to develop a plugin, I would need to know where it is 
possible to hook to change behaviour.

I'd say that a list of pluggable points of the code, from people who 
know very well the couchdb architecture, would be very useful. I didn't 
find such resource on the web, and I have the feeling that it doesn't 
exist. Would it be possible to have such a list, even in draft version 
just to begin. I can then contribute to the documentation to help future 
plugin developers.

Up to now I only counted three public plugins, including two real ones : 
CouchPerUser, GeoCouch and MyFirstCouchdbPlugin (and the new born LdapAuth)

I would like to know for instance if features that act more deep inside 
the couchdb engine, such as the validate_doc_read function, could be 
made as plugin ?

Thank you for your help,

Franck

On 15/09/2013 14:45, Jason Smith wrote:
> Hi, Aurélien.
>
> I think LDAP is a great candidate to convert to a plugin. The foundation is
> there however it is still more developer-focused than user-focused.
>
> Probably the best starting place is Jan's example plugin:
>
> https://github.com/janl/my-first-couchdb-plugin
>
> On Sun, Sep 15, 2013 at 7:38 PM, Aurélien Bénel <au...@utt.fr>
> wrote:
>> No idea?
>> Any plugin expert out there?
>>
>>> Hi everyone,
>>>
>>> In version 1.4, the feature that excites me the most is the plugin system. I see it as a way to foster innovation on CouchDB, letting people
>>> test unstable features, without having to weaken the core of CouchDB.
>>>
>>> However, I haven't found much on the Web about what can be done exactly
>>> as a plugin, and how difficult it is to turn a "feature hidden in some
>>> developer’s git repository" into a plugin.
>>>
>>> As an example of a long forgotten (yet needed) feature, let's take the LDAP authentication handler (
>>> https://github.com/chao/couchdb/commits/ldap_auth). Could it be turned into
>>> a plugin? Would it be easy?
>>>
>>>
>>> Regards,
>>>
>>> Aurélien


Re: Writing a Plugin : know couchdb core

Posted by Jan Lehnardt <ja...@apache.org>.
Heya Franck,

we are certainly thrilled about plugins, sorry about the radio-silence so far.

Like you point out, writing CouchDB plugins isn’t much different from CouchDB internals. That’s a good thing, now the bad thing is that CouchDB internals aren’t as well documented. The good thing again is, that they are relatively straightforward if you work from the HTTP API downwards.

We have an erlang@couchdb.apache.org mailing list to discuss these kinds of things and I did a write up there a year ago that explains what happens when you write a document top to bottom: http://mail-archives.apache.org/mod_mbox/couchdb-erlang/201211.mbox/%3cE873EE1D-5165-487D-B5D7-0AF9F2F09672@apache.org%3e

There is also https://github.com/apache/couchdb/blob/master/src/my-first-couchdb-plugin/README.md but I assume you found that already. It’s a good start, but it is not yet complete, e.g. the fun bits are missing :)

There is of course lots more, and the best way forward is to just dive in and try things out, look at how existing code does its thing and then just post questions here on erlang@ (either is fine).

Good luck and let us know how it goes! :)

Best
Jan
-- 



On 14 Dec 2013, at 10:02 , Franck Eyraud <fr...@nospam.yrnm.net> wrote:

> Hello,
> 
> It seems that plugin discussions don't create passionate debates... It's a pity because it is really a good feature, and since from what I understood taht the couchdb core might be reduced in the future, plugins will be always used more.
> 
> Maybe creating a plugin is not a in itself problem. I watched the interesting talk[1] from Jason Smith which is a very good start. And it made me realize that writing a plugin is in fact equivalent to writing a bit of code in couchdb core.
> 
> So what I need is to learn what a couchdb developer knows : couchdb architecture and API.
> 
> Is there any resource online where I can learn this stuff ? A quick start guide to develop in couchdb (especially for people who never used erlang before) ? Or is the only way to dig inside couchdb git tree and try to understand ? Before doing this, I want to be sure I won't loose too much time. So please people who entered the couchdb project later, how did you reach your level ?
> 
> Thanks for your help,
> 
> Franck
> 
> [1] http://www.youtube.com/watch?v=saNjXpE1h1Y&list=PLJa_sXrJUZb8ZuaQShicg6oWI682Bavjb&index=9
> On 05/12/2013 19:05, Franck Eyraud wrote:
>> Hello,
>> 
>> I cross post this since it seems better to follow up on the developers mailing list.
>> 
>> I started to work from Jan's my-first-couchdb-plugin to adapt the LDAP feature from chao into a couchDB plugin.
>> https://github.com/franck-eyraud/ldap-auth-couchdb-plugin
>> 
>> Up to now, I managed to do it, by adding an auth handler.
>> 
>> But in order to develop a plugin, I would need to know where it is possible to hook to change behaviour.
>> 
>> I'd say that a list of pluggable points of the code, from people who know very well the couchdb architecture, would be very useful. I didn't find such resource on the web, and I have the feeling that it doesn't exist. Would it be possible to have such a list, even in draft version just to begin. I can then contribute to the documentation to help future plugin developers.
>> 
>> Up to now I only counted three public plugins, including two real ones : CouchPerUser, GeoCouch and MyFirstCouchdbPlugin (and the new born LdapAuth)
>> 
>> I would like to know for instance if features that act more deep inside the couchdb engine, such as the validate_doc_read function, could be made as plugin ?
>> 
>> Thank you for your help,
>> 
>> Franck
>> 
>> On 15/09/2013 14:45, Jason Smith wrote:
>>> Hi, Aurélien.
>>> 
>>> I think LDAP is a great candidate to convert to a plugin. The foundation is
>>> there however it is still more developer-focused than user-focused.
>>> 
>>> Probably the best starting place is Jan's example plugin:
>>> 
>>> https://github.com/janl/my-first-couchdb-plugin
>>> 
>>> On Sun, Sep 15, 2013 at 7:38 PM, Aurélien Bénel <au...@utt.fr>
>>> wrote:
>>>> No idea?
>>>> Any plugin expert out there?
>>>> 
>>>>> Hi everyone,
>>>>> 
>>>>> In version 1.4, the feature that excites me the most is the plugin system. I see it as a way to foster innovation on CouchDB, letting people
>>>>> test unstable features, without having to weaken the core of CouchDB.
>>>>> 
>>>>> However, I haven't found much on the Web about what can be done exactly
>>>>> as a plugin, and how difficult it is to turn a "feature hidden in some
>>>>> developer’s git repository" into a plugin.
>>>>> 
>>>>> As an example of a long forgotten (yet needed) feature, let's take the LDAP authentication handler (
>>>>> https://github.com/chao/couchdb/commits/ldap_auth). Could it be turned into
>>>>> a plugin? Would it be easy?
>>>>> 
>>>>> 
>>>>> Regards,
>>>>> 
>>>>> Aurélien
>> 
> 


Re: Writing a Plugin : know couchdb core

Posted by Franck Eyraud <fr...@nospam.yrnm.net>.
Hi Alexander and Jan,

Thank you both of us for your answers.

I understand that the best way to learn is to dig into the code, I will 
use this
You gave me some good resources to complete the knowledge. Especially 
the erlang one; in fact, I'm not so afraid by how the erlang code is 
presented, but I might end up to use it in a too basic way and not use 
its whole power, so having an erlang doc will be also very useful.

Good idea also to look at another auth plugin, and I suppose that if you 
mentioned the XO_Auth to me, it means that it is well built (would be a 
pity to copy a bad project !)

Yes, I'll keep the list posted about how it goes, most probably after 
the Holidays.

As I mentioned in one of my first emails, if you already have some 
drafts for the planned developer guide, I might help to enhance it once 
I learned some more stuff !

Cheers,

Franck

On 14/12/2013 10:41, Alexander Shorin wrote:
> Hey Franck!
>
> On Sat, Dec 14, 2013 at 1:02 PM, Franck Eyraud
> <fr...@nospam.yrnm.net> wrote:
>> It seems that plugin discussions don't create passionate debates... It's a
>> pity because it is really a good feature, and since from what I understood
>> taht the couchdb core might be reduced in the future, plugins will be always
>> used more.
> There is nothing to discuss - it's very useful plugin and great idea
> to implement! Don't think that nobody cares because there was no
> responses from devs: most of them on CouchHack now and focused on
> code, fork merges and CouchDB (:
>
>> Maybe creating a plugin is not a in itself problem. I watched the
>> interesting talk[1] from Jason Smith which is a very good start. And it made
>> me realize that writing a plugin is in fact equivalent to writing a bit of
>> code in couchdb core.
>>
>> So what I need is to learn what a couchdb developer knows : couchdb
>> architecture and API.
>>
>> Is there any resource online where I can learn this stuff ? A quick start
>> guide to develop in couchdb (especially for people who never used erlang
>> before) ? Or is the only way to dig inside couchdb git tree and try to
>> understand ? Before doing this, I want to be sure I won't loose too much
>> time. So please people who entered the couchdb project later, how did you
>> reach your level ?
> Actually, there are plans to have such in our docs for developers
> guide section, but currently there is no any "official" information
> about. But we're working on to fix this (: However, you may found some
> useful blog posts over Internet and projects that are already hacked
> into CouchDB. For instance, you would love to see similar project that
> implements custom authentication with 3d party service:
>
> https://github.com/ocastalabs/CouchDB-XO_Auth
>
> About how to start...locate interesting module, take a look on his
> commit history, find out interesting functions, write some tests about
> to check and ensure in his behaviour or read existed ones. After that,
> create your own test case - it will be all "red", but thats ok. Trying
> to make it "green" will be your goal during developing or hacking.
> Don't make it too detailed from start, but you'll be happy to extend
> and improve it while adding new functions and featured. Not the best
> plan, but something to start from (; But anyway, don't fear erlang,
> don't fear write stuff and see it broken: in most cases it's easy to
> fix things quickly after 5 minutes googling or reading erlang docs or
> lyse[1].
>
> Happy hacking!
>
> [1]: http://learnyousomeerlang.com/
>
> --
> ,,,^..^,,,


Re: Writing a Plugin : know couchdb core

Posted by Alexander Shorin <kx...@gmail.com>.
Hey Franck!

On Sat, Dec 14, 2013 at 1:02 PM, Franck Eyraud
<fr...@nospam.yrnm.net> wrote:
>
> It seems that plugin discussions don't create passionate debates... It's a
> pity because it is really a good feature, and since from what I understood
> taht the couchdb core might be reduced in the future, plugins will be always
> used more.

There is nothing to discuss - it's very useful plugin and great idea
to implement! Don't think that nobody cares because there was no
responses from devs: most of them on CouchHack now and focused on
code, fork merges and CouchDB (:

> Maybe creating a plugin is not a in itself problem. I watched the
> interesting talk[1] from Jason Smith which is a very good start. And it made
> me realize that writing a plugin is in fact equivalent to writing a bit of
> code in couchdb core.
>
> So what I need is to learn what a couchdb developer knows : couchdb
> architecture and API.
>
> Is there any resource online where I can learn this stuff ? A quick start
> guide to develop in couchdb (especially for people who never used erlang
> before) ? Or is the only way to dig inside couchdb git tree and try to
> understand ? Before doing this, I want to be sure I won't loose too much
> time. So please people who entered the couchdb project later, how did you
> reach your level ?

Actually, there are plans to have such in our docs for developers
guide section, but currently there is no any "official" information
about. But we're working on to fix this (: However, you may found some
useful blog posts over Internet and projects that are already hacked
into CouchDB. For instance, you would love to see similar project that
implements custom authentication with 3d party service:

https://github.com/ocastalabs/CouchDB-XO_Auth

About how to start...locate interesting module, take a look on his
commit history, find out interesting functions, write some tests about
to check and ensure in his behaviour or read existed ones. After that,
create your own test case - it will be all "red", but thats ok. Trying
to make it "green" will be your goal during developing or hacking.
Don't make it too detailed from start, but you'll be happy to extend
and improve it while adding new functions and featured. Not the best
plan, but something to start from (; But anyway, don't fear erlang,
don't fear write stuff and see it broken: in most cases it's easy to
fix things quickly after 5 minutes googling or reading erlang docs or
lyse[1].

Happy hacking!

[1]: http://learnyousomeerlang.com/

--
,,,^..^,,,

Re: Writing a Plugin : know couchdb core

Posted by Franck Eyraud <fr...@nospam.yrnm.net>.
Hello,

It seems that plugin discussions don't create passionate debates... It's 
a pity because it is really a good feature, and since from what I 
understood taht the couchdb core might be reduced in the future, plugins 
will be always used more.

Maybe creating a plugin is not a in itself problem. I watched the 
interesting talk[1] from Jason Smith which is a very good start. And it 
made me realize that writing a plugin is in fact equivalent to writing a 
bit of code in couchdb core.

So what I need is to learn what a couchdb developer knows : couchdb 
architecture and API.

Is there any resource online where I can learn this stuff ? A quick 
start guide to develop in couchdb (especially for people who never used 
erlang before) ? Or is the only way to dig inside couchdb git tree and 
try to understand ? Before doing this, I want to be sure I won't loose 
too much time. So please people who entered the couchdb project later, 
how did you reach your level ?

Thanks for your help,

Franck

[1] 
http://www.youtube.com/watch?v=saNjXpE1h1Y&list=PLJa_sXrJUZb8ZuaQShicg6oWI682Bavjb&index=9
On 05/12/2013 19:05, Franck Eyraud wrote:
> Hello,
>
> I cross post this since it seems better to follow up on the developers 
> mailing list.
>
> I started to work from Jan's my-first-couchdb-plugin to adapt the LDAP 
> feature from chao into a couchDB plugin.
> https://github.com/franck-eyraud/ldap-auth-couchdb-plugin
>
> Up to now, I managed to do it, by adding an auth handler.
>
> But in order to develop a plugin, I would need to know where it is 
> possible to hook to change behaviour.
>
> I'd say that a list of pluggable points of the code, from people who 
> know very well the couchdb architecture, would be very useful. I 
> didn't find such resource on the web, and I have the feeling that it 
> doesn't exist. Would it be possible to have such a list, even in draft 
> version just to begin. I can then contribute to the documentation to 
> help future plugin developers.
>
> Up to now I only counted three public plugins, including two real ones 
> : CouchPerUser, GeoCouch and MyFirstCouchdbPlugin (and the new born 
> LdapAuth)
>
> I would like to know for instance if features that act more deep 
> inside the couchdb engine, such as the validate_doc_read function, 
> could be made as plugin ?
>
> Thank you for your help,
>
> Franck
>
> On 15/09/2013 14:45, Jason Smith wrote:
>> Hi, Aurélien.
>>
>> I think LDAP is a great candidate to convert to a plugin. The 
>> foundation is
>> there however it is still more developer-focused than user-focused.
>>
>> Probably the best starting place is Jan's example plugin:
>>
>> https://github.com/janl/my-first-couchdb-plugin
>>
>> On Sun, Sep 15, 2013 at 7:38 PM, Aurélien Bénel <au...@utt.fr>
>> wrote:
>>> No idea?
>>> Any plugin expert out there?
>>>
>>>> Hi everyone,
>>>>
>>>> In version 1.4, the feature that excites me the most is the plugin 
>>>> system. I see it as a way to foster innovation on CouchDB, letting 
>>>> people
>>>> test unstable features, without having to weaken the core of CouchDB.
>>>>
>>>> However, I haven't found much on the Web about what can be done 
>>>> exactly
>>>> as a plugin, and how difficult it is to turn a "feature hidden in some
>>>> developer’s git repository" into a plugin.
>>>>
>>>> As an example of a long forgotten (yet needed) feature, let's take 
>>>> the LDAP authentication handler (
>>>> https://github.com/chao/couchdb/commits/ldap_auth). Could it be 
>>>> turned into
>>>> a plugin? Would it be easy?
>>>>
>>>>
>>>> Regards,
>>>>
>>>> Aurélien
>