You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@couchdb.apache.org by "Chris Anderson (JIRA)" <ji...@apache.org> on 2010/08/16 19:17:16 UTC

[jira] Commented: (COUCHDB-855) New host manager

    [ https://issues.apache.org/jira/browse/COUCHDB-855?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12898993#action_12898993 ] 

Chris Anderson commented on COUCHDB-855:
----------------------------------------

patch looks great! thanks so much. only change I'd suggest is removing this change:

       basicView : {
         map : stringFun(function(doc) {
-          emit(doc.integer, doc.string);
+          if (doc.integer && doc.string)
+            emit(doc.integer, doc.string);
         })
       },
       withReduce : {
         map : stringFun(function(doc) {
-          emit(doc.integer, doc.string);
+          if (doc.integer && doc.string)
+            emit(doc.integer, doc.string);
         }),


I know these guard conditions are good practice, but in real life there are lots of "bad" views out there, so we should ensure the tests pass even without the guards.

> New host manager
> ----------------
>
>                 Key: COUCHDB-855
>                 URL: https://issues.apache.org/jira/browse/COUCHDB-855
>             Project: CouchDB
>          Issue Type: Improvement
>    Affects Versions: 1.1
>            Reporter: Benoit Chesneau
>            Assignee: Benoit Chesneau
>             Fix For: 1.1
>
>         Attachments: 0001-New-vhost-manager.-allows-dynamic-add-of-vhosts-with.patch
>
>
> New vhost manager. allows dynamic add of vhosts without restart, wildcard in vhost and specific functions in erlang by kind of domain. It also fix issue in etap test (160) .
> Find attached to this ticket the patch. It is also available in my github repo :
> http://github.com/benoitc/couchdb/commit/435c756cc6e687886cc7055302963f422cf0e161
> more details :
> This gen_server keep state of vhosts added to the ini and try to
> match the Host header (or forwarded) against rules built against
> vhost list. 
> Declaration of vhosts take place in the configuration file :
> [vhosts]
> example.com = /example
> *.example.com = /example
> The first line will rewrite the rquest to display the content of the
> example database. This rule works only if the Host header is
> 'example.com' and won't work for CNAMEs. Second rule on the other hand
> match all CNAMES to example db. So www.example.com or db.example.com
> will work.
> The wildcard ('*') should always be the last in the cnames:
>      "*.db.example.com = /"  will match all cname on top of db
> examples to the root of the machine. (for now no rewriting is
> possible).
> By default vhosts redirection is handle by the function
> couch_httpd_vhost:redirect_to_vhost, but you could pass per vhost a
> specific function :
>      "*.domain.com" = {Module, Func}"
> The function take the Mochiweb Request object and should return a new
> Mochiweb Request object.
> You could also change the default function to handle request by
> changing the setting `redirect_vhost_handler` in `httpd` section of
> the Ini:
>       [httpd]
>       redirect_vhost_handler = {Module, Fun}
> The function take 2 args : the mochiweb request object and the target
> path. 

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Re: [jira] Commented: (COUCHDB-855) New host manager

Posted by Klaus Trainer <kl...@web.de>.
> Now I'm confused... I guess I put the comment about your patch on the
> wrong ticket?

Yes, exactly.

> >> patch looks great! thanks so much. only change I'd suggest is removing this change:
> >> 
> >>       basicView : {
> >>         map : stringFun(function(doc) {
> >> -          emit(doc.integer, doc.string);
> >> +          if (doc.integer && doc.string)
> >> +            emit(doc.integer, doc.string);
> >>         })
> >>       },
> >>       withReduce : {
> >>         map : stringFun(function(doc) {
> >> -          emit(doc.integer, doc.string);
> >> +          if (doc.integer && doc.string)
> >> +            emit(doc.integer, doc.string);
> >>         }),
> >> 
> >> 
> >> I know these guard conditions are good practice, but in real life there are lots of "bad" views out there, so we should ensure the tests pass even without the guards.

The if-condition is necessary for my test. Later in it, I add documents
without "integer" and "string" fields. The if-condition prevents these
documents from changing the view indices. That is, I assert that the
view indices are equal to the ones before, and that the ETag has not
changed.

Please tell me if you still think the if-condition shouldn't be there,
so I'd just add another design document for my test instead.


- Klaus


On Tue, 2010-08-17 at 18:24 -0700, J Chris Anderson wrote:
> On Aug 16, 2010, at 11:52 AM, Klaus Trainer wrote:
> 
> > Hey Chris,
> > 
> > I guess there was a race condition while you processed Benoit's and my
> > patch in parallel.
> > 
> 

> 
> Chris
> 
> > Cheers,
> > Klaus
> > 
> > 
> > On Mon, 2010-08-16 at 13:17 -0400, Chris Anderson (JIRA) wrote:
> >> [ https://issues.apache.org/jira/browse/COUCHDB-855?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12898993#action_12898993 ] 
> >> 
> >> Chris Anderson commented on COUCHDB-855:
> >> ----------------------------------------
> >> 
> >> patch looks great! thanks so much. only change I'd suggest is removing this change:
> >> 
> >>       basicView : {
> >>         map : stringFun(function(doc) {
> >> -          emit(doc.integer, doc.string);
> >> +          if (doc.integer && doc.string)
> >> +            emit(doc.integer, doc.string);
> >>         })
> >>       },
> >>       withReduce : {
> >>         map : stringFun(function(doc) {
> >> -          emit(doc.integer, doc.string);
> >> +          if (doc.integer && doc.string)
> >> +            emit(doc.integer, doc.string);
> >>         }),
> >> 
> >> 
> >> I know these guard conditions are good practice, but in real life there are lots of "bad" views out there, so we should ensure the tests pass even without the guards.
> >> 
> >>> New host manager
> >>> ----------------
> >>> 
> >>>                Key: COUCHDB-855
> >>>                URL: https://issues.apache.org/jira/browse/COUCHDB-855
> >>>            Project: CouchDB
> >>>         Issue Type: Improvement
> >>>   Affects Versions: 1.1
> >>>           Reporter: Benoit Chesneau
> >>>           Assignee: Benoit Chesneau
> >>>            Fix For: 1.1
> >>> 
> >>>        Attachments: 0001-New-vhost-manager.-allows-dynamic-add-of-vhosts-with.patch
> >>> 
> >>> 
> >>> New vhost manager. allows dynamic add of vhosts without restart, wildcard in vhost and specific functions in erlang by kind of domain. It also fix issue in etap test (160) .
> >>> Find attached to this ticket the patch. It is also available in my github repo :
> >>> http://github.com/benoitc/couchdb/commit/435c756cc6e687886cc7055302963f422cf0e161
> >>> more details :
> >>> This gen_server keep state of vhosts added to the ini and try to
> >>> match the Host header (or forwarded) against rules built against
> >>> vhost list. 
> >>> Declaration of vhosts take place in the configuration file :
> >>> [vhosts]
> >>> example.com = /example
> >>> *.example.com = /example
> >>> The first line will rewrite the rquest to display the content of the
> >>> example database. This rule works only if the Host header is
> >>> 'example.com' and won't work for CNAMEs. Second rule on the other hand
> >>> match all CNAMES to example db. So www.example.com or db.example.com
> >>> will work.
> >>> The wildcard ('*') should always be the last in the cnames:
> >>>     "*.db.example.com = /"  will match all cname on top of db
> >>> examples to the root of the machine. (for now no rewriting is
> >>> possible).
> >>> By default vhosts redirection is handle by the function
> >>> couch_httpd_vhost:redirect_to_vhost, but you could pass per vhost a
> >>> specific function :
> >>>     "*.domain.com" = {Module, Func}"
> >>> The function take the Mochiweb Request object and should return a new
> >>> Mochiweb Request object.
> >>> You could also change the default function to handle request by
> >>> changing the setting `redirect_vhost_handler` in `httpd` section of
> >>> the Ini:
> >>>      [httpd]
> >>>      redirect_vhost_handler = {Module, Fun}
> >>> The function take 2 args : the mochiweb request object and the target
> >>> path. 
> >> 
> > 
> > 



Re: [jira] Commented: (COUCHDB-855) New host manager

Posted by J Chris Anderson <jc...@apache.org>.
On Aug 16, 2010, at 11:52 AM, Klaus Trainer wrote:

> Hey Chris,
> 
> I guess there was a race condition while you processed Benoit's and my
> patch in parallel.
> 

Now I'm confused... I guess I put the comment about your patch on the wrong ticket?

Chris

> Cheers,
> Klaus
> 
> 
> On Mon, 2010-08-16 at 13:17 -0400, Chris Anderson (JIRA) wrote:
>> [ https://issues.apache.org/jira/browse/COUCHDB-855?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12898993#action_12898993 ] 
>> 
>> Chris Anderson commented on COUCHDB-855:
>> ----------------------------------------
>> 
>> patch looks great! thanks so much. only change I'd suggest is removing this change:
>> 
>>       basicView : {
>>         map : stringFun(function(doc) {
>> -          emit(doc.integer, doc.string);
>> +          if (doc.integer && doc.string)
>> +            emit(doc.integer, doc.string);
>>         })
>>       },
>>       withReduce : {
>>         map : stringFun(function(doc) {
>> -          emit(doc.integer, doc.string);
>> +          if (doc.integer && doc.string)
>> +            emit(doc.integer, doc.string);
>>         }),
>> 
>> 
>> I know these guard conditions are good practice, but in real life there are lots of "bad" views out there, so we should ensure the tests pass even without the guards.
>> 
>>> New host manager
>>> ----------------
>>> 
>>>                Key: COUCHDB-855
>>>                URL: https://issues.apache.org/jira/browse/COUCHDB-855
>>>            Project: CouchDB
>>>         Issue Type: Improvement
>>>   Affects Versions: 1.1
>>>           Reporter: Benoit Chesneau
>>>           Assignee: Benoit Chesneau
>>>            Fix For: 1.1
>>> 
>>>        Attachments: 0001-New-vhost-manager.-allows-dynamic-add-of-vhosts-with.patch
>>> 
>>> 
>>> New vhost manager. allows dynamic add of vhosts without restart, wildcard in vhost and specific functions in erlang by kind of domain. It also fix issue in etap test (160) .
>>> Find attached to this ticket the patch. It is also available in my github repo :
>>> http://github.com/benoitc/couchdb/commit/435c756cc6e687886cc7055302963f422cf0e161
>>> more details :
>>> This gen_server keep state of vhosts added to the ini and try to
>>> match the Host header (or forwarded) against rules built against
>>> vhost list. 
>>> Declaration of vhosts take place in the configuration file :
>>> [vhosts]
>>> example.com = /example
>>> *.example.com = /example
>>> The first line will rewrite the rquest to display the content of the
>>> example database. This rule works only if the Host header is
>>> 'example.com' and won't work for CNAMEs. Second rule on the other hand
>>> match all CNAMES to example db. So www.example.com or db.example.com
>>> will work.
>>> The wildcard ('*') should always be the last in the cnames:
>>>     "*.db.example.com = /"  will match all cname on top of db
>>> examples to the root of the machine. (for now no rewriting is
>>> possible).
>>> By default vhosts redirection is handle by the function
>>> couch_httpd_vhost:redirect_to_vhost, but you could pass per vhost a
>>> specific function :
>>>     "*.domain.com" = {Module, Func}"
>>> The function take the Mochiweb Request object and should return a new
>>> Mochiweb Request object.
>>> You could also change the default function to handle request by
>>> changing the setting `redirect_vhost_handler` in `httpd` section of
>>> the Ini:
>>>      [httpd]
>>>      redirect_vhost_handler = {Module, Fun}
>>> The function take 2 args : the mochiweb request object and the target
>>> path. 
>> 
> 
> 


Re: [jira] Commented: (COUCHDB-855) New host manager

Posted by Klaus Trainer <kl...@web.de>.
Hey Chris,

I guess there was a race condition while you processed Benoit's and my
patch in parallel.

Cheers,
Klaus


On Mon, 2010-08-16 at 13:17 -0400, Chris Anderson (JIRA) wrote:
> [ https://issues.apache.org/jira/browse/COUCHDB-855?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12898993#action_12898993 ] 
> 
> Chris Anderson commented on COUCHDB-855:
> ----------------------------------------
> 
> patch looks great! thanks so much. only change I'd suggest is removing this change:
> 
>        basicView : {
>          map : stringFun(function(doc) {
> -          emit(doc.integer, doc.string);
> +          if (doc.integer && doc.string)
> +            emit(doc.integer, doc.string);
>          })
>        },
>        withReduce : {
>          map : stringFun(function(doc) {
> -          emit(doc.integer, doc.string);
> +          if (doc.integer && doc.string)
> +            emit(doc.integer, doc.string);
>          }),
> 
> 
> I know these guard conditions are good practice, but in real life there are lots of "bad" views out there, so we should ensure the tests pass even without the guards.
> 
> > New host manager
> > ----------------
> >
> >                 Key: COUCHDB-855
> >                 URL: https://issues.apache.org/jira/browse/COUCHDB-855
> >             Project: CouchDB
> >          Issue Type: Improvement
> >    Affects Versions: 1.1
> >            Reporter: Benoit Chesneau
> >            Assignee: Benoit Chesneau
> >             Fix For: 1.1
> >
> >         Attachments: 0001-New-vhost-manager.-allows-dynamic-add-of-vhosts-with.patch
> >
> >
> > New vhost manager. allows dynamic add of vhosts without restart, wildcard in vhost and specific functions in erlang by kind of domain. It also fix issue in etap test (160) .
> > Find attached to this ticket the patch. It is also available in my github repo :
> > http://github.com/benoitc/couchdb/commit/435c756cc6e687886cc7055302963f422cf0e161
> > more details :
> > This gen_server keep state of vhosts added to the ini and try to
> > match the Host header (or forwarded) against rules built against
> > vhost list. 
> > Declaration of vhosts take place in the configuration file :
> > [vhosts]
> > example.com = /example
> > *.example.com = /example
> > The first line will rewrite the rquest to display the content of the
> > example database. This rule works only if the Host header is
> > 'example.com' and won't work for CNAMEs. Second rule on the other hand
> > match all CNAMES to example db. So www.example.com or db.example.com
> > will work.
> > The wildcard ('*') should always be the last in the cnames:
> >      "*.db.example.com = /"  will match all cname on top of db
> > examples to the root of the machine. (for now no rewriting is
> > possible).
> > By default vhosts redirection is handle by the function
> > couch_httpd_vhost:redirect_to_vhost, but you could pass per vhost a
> > specific function :
> >      "*.domain.com" = {Module, Func}"
> > The function take the Mochiweb Request object and should return a new
> > Mochiweb Request object.
> > You could also change the default function to handle request by
> > changing the setting `redirect_vhost_handler` in `httpd` section of
> > the Ini:
> >       [httpd]
> >       redirect_vhost_handler = {Module, Fun}
> > The function take 2 args : the mochiweb request object and the target
> > path. 
>