CORS feature.

2011-11-28 Thread Benoit Chesneau
Hi,
We had a great discussion today Jason, Randall and me about the CORS
feature [1] .
I'm positing here the current result that you can find on friendpaste
[2] too. I think it's
a pretty good start and we can begin to code it. Implementation is
mostly a merge
between jason proposal and mine imo. Thoughts ?

- benoît

[1] https://issues.apache.org/jira/browse/COUCHDB-431
[2] http://friendpaste.com/4q1zeNUEtPFS7XbioPYYzM

guidelinees :
--

- rules shoudl be based on host .
- rules depending on the resource :
  - server : rules defined in .ini
  - db : rules defined in .db

- default cors policy :
- allows credential = false
- cors enabled
- cors can be disabled globaly



rules definiton :

global wide

[httpd]
cors_enabled = true

[origins]
domain.tld = http://origin.tld, https://origin.tld

[http://origin.tld]
allow_methods = GET, POST
allow_headers = x-couchdb-...
allow_credentials = false


[https://origin.tld]
allow_methods = GET, PUT, POST, DELETE
allow_headers = x-couchdb-...
allow_credentials = true
allow_server_admins = true
max-age = 36000


ond db _security object :


{
origins: {
domain.tld: [
{http://origin.tld: { allow_methods: GET, POST,
...}
]
}
}



work flow :

is origins list empty in ini
yes - is admin party set ?
  yes - return * , credentials false (with a good caching policy)
  no - stop
no -
  is origin in .ini ?
  yes -
is origin in list ?
yes -
  set the cors headers based on .ini
  then are we on a db resource ?
yes -
  apply the intersection of .ini with db resource
no - stop
  no -


[jira] [Commented] (COUCHDB-1289) heartbeats skipped when continuous changes feed filter function produces no results

2011-11-28 Thread Filipe Manana (Commented) (JIRA)

[ 
https://issues.apache.org/jira/browse/COUCHDB-1289?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13158338#comment-13158338
 ] 

Filipe Manana commented on COUCHDB-1289:


Bob, +1.
You did most of the hard work, no need to set me as the author for one of them.
Lets push it to master and 1.2.x?

Thanks :)

 heartbeats skipped when continuous changes feed filter function produces no 
 results
 ---

 Key: COUCHDB-1289
 URL: https://issues.apache.org/jira/browse/COUCHDB-1289
 Project: CouchDB
  Issue Type: Bug
  Components: Database Core
Reporter: Bob Dionne
Assignee: Bob Dionne
Priority: Minor
 Attachments: 0001-Ensure-heartbeats-are-not-skipped.patch, 
 0002-Failing-etap-for-heartbeats-skipped.patch


 if the changes feed has a filter function that produces no results, 
 db_updated messages will still be sent and the heartbeat timeout will never 
 be reached.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira




Re: CORS feature.

2011-11-28 Thread Benoit Chesneau
On Mon, Nov 28, 2011 at 11:38 AM, Benoit Chesneau bchesn...@gmail.com wrote:
 Hi,
 We had a great discussion today Jason, Randall and me about the CORS
 feature [1] .
 I'm positing here the current result that you can find on friendpaste
 [2] too. I think it's
 a pretty good start and we can begin to code it. Implementation is
 mostly a merge
 between jason proposal and mine imo. Thoughts ?

 - benoît

 [1] https://issues.apache.org/jira/browse/COUCHDB-431
 [2] http://friendpaste.com/4q1zeNUEtPFS7XbioPYYzM

 guidelinees :
 --

    - rules shoudl be based on host .
    - rules depending on the resource :
      - server : rules defined in .ini
      - db : rules defined in .db

    - default cors policy :
        - allows credential = false
        - cors enabled
    - cors can be disabled globaly



    rules definiton :

    global wide

    [httpd]
    cors_enabled = true

    [origins]
    domain.tld = http://origin.tld, https://origin.tld

    [http://origin.tld]
    allow_methods = GET, POST
    allow_headers = x-couchdb-...
    allow_credentials = false


    [https://origin.tld]
    allow_methods = GET, PUT, POST, DELETE
    allow_headers = x-couchdb-...
    allow_credentials = true
    allow_server_admins = true
    max-age = 36000


    ond db _security object :


    {
        origins: {
            domain.tld: [
                {http://origin.tld: { allow_methods: GET, POST,
    ...}
            ]
        }
    }



    work flow :

    is origins list empty in ini
    yes - is admin party set ?
      yes - return * , credentials false (with a good caching policy)
      no - stop
    no -
      is origin in .ini ?
      yes -
        is origin in list ?
        yes -
          set the cors headers based on .ini
          then are we on a db resource ?
            yes -
              apply the intersection of .ini with db resource
        no - stop
      no -



quick not about hosts. It should be abble to set '*' to manage origins
for any hosts.

- benoît


[jira] [Resolved] (COUCHDB-1289) heartbeats skipped when continuous changes feed filter function produces no results

2011-11-28 Thread Bob Dionne (Resolved) (JIRA)

 [ 
https://issues.apache.org/jira/browse/COUCHDB-1289?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Bob Dionne resolved COUCHDB-1289.
-

Resolution: Fixed

thanks Filipe

 heartbeats skipped when continuous changes feed filter function produces no 
 results
 ---

 Key: COUCHDB-1289
 URL: https://issues.apache.org/jira/browse/COUCHDB-1289
 Project: CouchDB
  Issue Type: Bug
  Components: Database Core
Reporter: Bob Dionne
Assignee: Bob Dionne
Priority: Minor
  Labels: patch
 Fix For: 1.2

 Attachments: 0001-Ensure-heartbeats-are-not-skipped.patch, 
 0002-Failing-etap-for-heartbeats-skipped.patch


 if the changes feed has a filter function that produces no results, 
 db_updated messages will still be sent and the heartbeat timeout will never 
 be reached.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira




[jira] [Updated] (COUCHDB-1289) heartbeats skipped when continuous changes feed filter function produces no results

2011-11-28 Thread Bob Dionne (Updated) (JIRA)

 [ 
https://issues.apache.org/jira/browse/COUCHDB-1289?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Bob Dionne updated COUCHDB-1289:


Fix Version/s: 1.2
   Labels: patch  (was: )

 heartbeats skipped when continuous changes feed filter function produces no 
 results
 ---

 Key: COUCHDB-1289
 URL: https://issues.apache.org/jira/browse/COUCHDB-1289
 Project: CouchDB
  Issue Type: Bug
  Components: Database Core
Reporter: Bob Dionne
Assignee: Bob Dionne
Priority: Minor
  Labels: patch
 Fix For: 1.2

 Attachments: 0001-Ensure-heartbeats-are-not-skipped.patch, 
 0002-Failing-etap-for-heartbeats-skipped.patch


 if the changes feed has a filter function that produces no results, 
 db_updated messages will still be sent and the heartbeat timeout will never 
 be reached.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira




[jira] [Commented] (COUCHDB-1289) heartbeats skipped when continuous changes feed filter function produces no results

2011-11-28 Thread Filipe Manana (Commented) (JIRA)

[ 
https://issues.apache.org/jira/browse/COUCHDB-1289?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13158378#comment-13158378
 ] 

Filipe Manana commented on COUCHDB-1289:


(Jira messed up with the patch indentation)

 heartbeats skipped when continuous changes feed filter function produces no 
 results
 ---

 Key: COUCHDB-1289
 URL: https://issues.apache.org/jira/browse/COUCHDB-1289
 Project: CouchDB
  Issue Type: Bug
  Components: Database Core
Reporter: Bob Dionne
Assignee: Bob Dionne
Priority: Minor
  Labels: patch
 Fix For: 1.2

 Attachments: 0001-Ensure-heartbeats-are-not-skipped.patch, 
 0002-Failing-etap-for-heartbeats-skipped.patch


 if the changes feed has a filter function that produces no results, 
 db_updated messages will still be sent and the heartbeat timeout will never 
 be reached.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira




[jira] [Commented] (COUCHDB-1289) heartbeats skipped when continuous changes feed filter function produces no results

2011-11-28 Thread Filipe Manana (Commented) (JIRA)

[ 
https://issues.apache.org/jira/browse/COUCHDB-1289?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13158376#comment-13158376
 ] 

Filipe Manana commented on COUCHDB-1289:


Bob, just caught another case where the default TimeoutFun will be called 
(which stops the streaming immediately):


From 7160021512161e3fa8f83165adc1a64285da6518 Mon Sep 17 00:00:00 2001
From: Filipe David Borba Manana fdman...@apache.org
Date: Mon, 28 Nov 2011 12:30:50 +
Subject: [PATCH 2/2] Make reset_heartbeat/0 a no-op

If no heartbeat option was given, the couch_changes heartbeat
function should really be a no-op, that is, to not set the
last_changes_heartbeat to the current time, otherwise the
default TimeoutFun (when no heartbeat option is given) might
be called which causes the changes feed to stop immediately
before folding the whole seq tree.
---
 src/couchdb/couch_changes.erl |7 ++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/src/couchdb/couch_changes.erl b/src/couchdb/couch_changes.erl
index f124567..72ee346 100644
--- a/src/couchdb/couch_changes.erl
+++ b/src/couchdb/couch_changes.erl
@@ -531,7 +531,12 @@ get_rest_db_updated(UserAcc) -
 end.
 
 reset_heartbeat() -
-put(last_changes_heartbeat,now()).
+case get(last_changes_heartbeat) of
+undefined -
+ok;
+_ -
+put(last_changes_heartbeat, now())
+end.
 
 maybe_heartbeat(Timeout, TimeoutFun, Acc) -
 Before = get(last_changes_heartbeat),
-- 
1.7.4.4

Do you agree?

 heartbeats skipped when continuous changes feed filter function produces no 
 results
 ---

 Key: COUCHDB-1289
 URL: https://issues.apache.org/jira/browse/COUCHDB-1289
 Project: CouchDB
  Issue Type: Bug
  Components: Database Core
Reporter: Bob Dionne
Assignee: Bob Dionne
Priority: Minor
  Labels: patch
 Fix For: 1.2

 Attachments: 0001-Ensure-heartbeats-are-not-skipped.patch, 
 0002-Failing-etap-for-heartbeats-skipped.patch


 if the changes feed has a filter function that produces no results, 
 db_updated messages will still be sent and the heartbeat timeout will never 
 be reached.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira




[jira] [Updated] (COUCHDB-1289) heartbeats skipped when continuous changes feed filter function produces no results

2011-11-28 Thread Filipe Manana (Updated) (JIRA)

 [ 
https://issues.apache.org/jira/browse/COUCHDB-1289?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Filipe Manana updated COUCHDB-1289:
---

Attachment: 0002-Make-reset_heartbeat-0-a-no-op.patch

Added the patch as an attachment instead

 heartbeats skipped when continuous changes feed filter function produces no 
 results
 ---

 Key: COUCHDB-1289
 URL: https://issues.apache.org/jira/browse/COUCHDB-1289
 Project: CouchDB
  Issue Type: Bug
  Components: Database Core
Reporter: Bob Dionne
Assignee: Bob Dionne
Priority: Minor
  Labels: patch
 Fix For: 1.2

 Attachments: 0001-Ensure-heartbeats-are-not-skipped.patch, 
 0002-Failing-etap-for-heartbeats-skipped.patch, 
 0002-Make-reset_heartbeat-0-a-no-op.patch


 if the changes feed has a filter function that produces no results, 
 db_updated messages will still be sent and the heartbeat timeout will never 
 be reached.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira




[jira] [Closed] (COUCHDB-804) Rename couch_file:make_blocks to couch_file:add_block_prefixes

2011-11-28 Thread Andrey Somov (Closed) (JIRA)

 [ 
https://issues.apache.org/jira/browse/COUCHDB-804?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Andrey Somov closed COUCHDB-804.


Resolution: Not A Problem

No need to fix

 Rename couch_file:make_blocks to  couch_file:add_block_prefixes
 ---

 Key: COUCHDB-804
 URL: https://issues.apache.org/jira/browse/COUCHDB-804
 Project: CouchDB
  Issue Type: Improvement
  Components: Documentation
Reporter: Andrey Somov
Priority: Trivial
 Attachments: couch_file-patch1.txt

   Original Estimate: 1h
  Remaining Estimate: 1h

 Rename couch_file:make_blocks to  couch_file:add_block_prefixes to be 
 symmetrical with  its counterpart - couch_file:remove_block_prefixes
 Add a few descriptions for functions

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira




Re: CORS feature.

2011-11-28 Thread Randall Leeds
On Mon, Nov 28, 2011 at 02:50, Benoit Chesneau bchesn...@gmail.com wrote:
 On Mon, Nov 28, 2011 at 11:38 AM, Benoit Chesneau bchesn...@gmail.com wrote:
 Hi,
 We had a great discussion today Jason, Randall and me about the CORS
 feature [1] .
 I'm positing here the current result that you can find on friendpaste
 [2] too. I think it's
 a pretty good start and we can begin to code it. Implementation is
 mostly a merge
 between jason proposal and mine imo. Thoughts ?

 - benoît

 [1] https://issues.apache.org/jira/browse/COUCHDB-431
 [2] http://friendpaste.com/4q1zeNUEtPFS7XbioPYYzM

 guidelinees :
 --

    - rules shoudl be based on host .
    - rules depending on the resource :
      - server : rules defined in .ini
      - db : rules defined in .db

    - default cors policy :
        - allows credential = false
        - cors enabled
    - cors can be disabled globaly



    rules definiton :

    global wide

    [httpd]
    cors_enabled = true

    [origins]
    domain.tld = http://origin.tld, https://origin.tld

    [http://origin.tld]
    allow_methods = GET, POST
    allow_headers = x-couchdb-...
    allow_credentials = false


    [https://origin.tld]
    allow_methods = GET, PUT, POST, DELETE
    allow_headers = x-couchdb-...
    allow_credentials = true
    allow_server_admins = true
    max-age = 36000


    ond db _security object :


    {
        origins: {
            domain.tld: [
                {http://origin.tld: { allow_methods: GET, POST,
    ...}
            ]
        }
    }



    work flow :

    is origins list empty in ini
    yes - is admin party set ?
      yes - return * , credentials false (with a good caching policy)
      no - stop
    no -
      is origin in .ini ?
      yes -
        is origin in list ?
        yes -
          set the cors headers based on .ini
          then are we on a db resource ?
            yes -
              apply the intersection of .ini with db resource
        no - stop
      no -


This last bit is wrong, IMO. The paste has an updated version.
I also simplified it just now to distinguish between /db(/...)
resources and special paths (/_uuids, etc).
My current suggestion is to use the db _security object when
available, and fall back to .ini config.
This allows admins to configure .ini and never have to touch dbs, but
db administrators can configure their own CORS.
Of course, server admins can still disable cors globally.
I feel like this hits all the use cases. Also the flow in the paste
now explains neatly how a chain of rewrites from dbs A-B-C would
have to check CORS permissions for each db it touches.

http://friendpaste.com/4q1zeNUEtPFS7XbioPYYzM



 quick not about hosts. It should be abble to set '*' to manage origins
 for any hosts.

 - benoît



Re: [VOTE] Apache CouchDB new docs proposal

2011-11-28 Thread Joan Touzet
On Sat, Nov 26, 2011 at 11:40:41PM +, Noah Slater wrote:
 Cool idea.

Agreed! As part of the coursework I'm planning for January, I can start
contributing back class notes and information as well. This would be the
start of documentation about how the code is laid out, formatting, etc.
I see this as complementary, and whoever signs up for the course can
also contribute at least 30-60 minutes of documentation cleanup as well.

If the course is successful, as it is iterated, so too should new groups
of students be available to help out as well. With any luck this will be
self-sustaining.

 I have created a wiki page:
 
 http://wiki.apache.org/couchdb/SourceDocumentation

I'll add this to the wiki right now.

-Joan


Re: [VOTE] Apache CouchDB new docs proposal

2011-11-28 Thread Noah Slater
Do you think stuff like coding standards, and conventions, might be better
documented on the wiki?

I was seeing this as more of an appendix style look-up for regular CouchDB
users.

On Mon, Nov 28, 2011 at 8:24 PM, Joan Touzet jo...@atypical.net wrote:

 On Sat, Nov 26, 2011 at 11:40:41PM +, Noah Slater wrote:
  Cool idea.

 Agreed! As part of the coursework I'm planning for January, I can start
 contributing back class notes and information as well. This would be the
 start of documentation about how the code is laid out, formatting, etc.
 I see this as complementary, and whoever signs up for the course can
 also contribute at least 30-60 minutes of documentation cleanup as well.

 If the course is successful, as it is iterated, so too should new groups
 of students be available to help out as well. With any luck this will be
 self-sustaining.

  I have created a wiki page:
 
  http://wiki.apache.org/couchdb/SourceDocumentation

 I'll add this to the wiki right now.

 -Joan



Re: [VOTE] Apache CouchDB new docs proposal

2011-11-28 Thread Noah Slater
Fair enough.

On Tue, Nov 29, 2011 at 12:49 AM, Randall Leeds randall.le...@gmail.comwrote:

 On Mon, Nov 28, 2011 at 15:09, Noah Slater nsla...@tumbolia.org wrote:
  Do you think stuff like coding standards, and conventions, might be
 better
  documented on the wiki?
 

 I don't have any problem with developer documentation in the source
 and installed documentation. For one, as we develop our plugin system
 some plugin developers may develop against couch using just the .hrl
 files from an installation. These plugins may want to increase their
 chance of going upstream by following the project coding conventions.

  I was seeing this as more of an appendix style look-up for regular
 CouchDB
  users.
 
  On Mon, Nov 28, 2011 at 8:24 PM, Joan Touzet jo...@atypical.net wrote:
 
  On Sat, Nov 26, 2011 at 11:40:41PM +, Noah Slater wrote:
   Cool idea.
 
  Agreed! As part of the coursework I'm planning for January, I can start
  contributing back class notes and information as well. This would be the
  start of documentation about how the code is laid out, formatting, etc.
  I see this as complementary, and whoever signs up for the course can
  also contribute at least 30-60 minutes of documentation cleanup as well.
 
  If the course is successful, as it is iterated, so too should new groups
  of students be available to help out as well. With any luck this will be
  self-sustaining.
 
   I have created a wiki page:
  
   http://wiki.apache.org/couchdb/SourceDocumentation
 
  I'll add this to the wiki right now.
 
  -Joan