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

ASF GitHub Bot commented on COUCHDB-2961:
-----------------------------------------

GitHub user kxepal opened a pull request:

    https://github.com/apache/couchdb-couch/pull/149

    Emit heartbeats until feed timeout

    COUCHDB-2961

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/kxepal/couchdb-couch 2961-heartbeat-timeout

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/couchdb-couch/pull/149.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #149
    
----
commit c31d210d864cd164b2e00c1a2600f73756ef9173
Author: Alexander Shorin <[email protected]>
Date:   2016-03-09T15:50:15Z

    Emit heartbeats until feed timeout
    
    COUCHDB-2961

----


> Let heartbeat work together with timeout for changes feed
> ---------------------------------------------------------
>
>                 Key: COUCHDB-2961
>                 URL: https://issues.apache.org/jira/browse/COUCHDB-2961
>             Project: CouchDB
>          Issue Type: Improvement
>          Components: HTTP Interface
>            Reporter: Alexander Shorin
>
> What do we have now.
> Changes feeds accepts two query parameters: heartbeat and timeout. The 
> heartbeat defines interval of sending heartbeat events (the {{\n}} for 
> continuous and longpoll feeds, special event for eventsource one). The 
> timeout defines the max time to wait for the changes and if nothing happened, 
> CouchDB terminates the feed.
> When you specify heartbeat with timeout together, say 
> {{http://localhost:5984/db/_changes?heartbeat=1000&timeout=5000&feed=continuous}}
>  I guess everyone would expect that we want to receive heartbeats every 1 
> second and terminate the feed after 5 seconds of inactivity. However, timeout 
> parameter will get ignored and we'll receive heartbeat every second forever.
> How it should work:
> Assume we want to listen continuous changes feed, receive heartbeats every 3 
> seconds and terminate the feed after 10 seconds of inactivity. Then the 
> request will be sort of:
> {code}
> http://localhost:5984/db/_changes?feed=continuous&timeout=10000&heartbeat=3000
> {code}
> And our expected communication:
> {code}
> - - C - - - H - - - H - C - - - H - - - H - - - H - T
> 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 
> 0                   1                   2            
> Legend:
> C - change event
> H - heartbeat
> T - termination
> {code}
> So what we need is to not reset timeout timer by sending heartbeats, but do 
> that by sending real document changes.
> Actually, current implementation swallow timeout parameter, replacing it with 
> heartbeat value and replaces callback that stops the feed with the one that 
> generates heartbeats. The fix should be trivial.
> To preserve backward compatibility we may use default timeout as infinity 
> (the code already supports that) if only heartbeat was explicitly specified.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to