Create a new ChangesFollower using the supplied client and params that
suppress transient errors and retry for as long as the given errorTolerance
duration.
CloudantV1 client instance to use to make requests
Changes feed params
Optional
errorTolerance: numberthe duration to suppress errors, measured from the previous
successful request. Use 0
to disable error suppression and terminate this ChangesFollower
on any failed request.
Return all available changes and keep listening for new changes until reaching an end condition.
The end conditions are:
The same change may be received more than once.
at least one ChangesResultItem per change
if:
Return all available changes until there are no further changes pending or reaching an end condition.
The end conditions are:
The same change may be received more than once.
at least one ChangesResultItem per change
if:
Stop this ChangesFollower.
if start or startOneOff was not called first
A helper for using the changes feed.
There are two modes of operation:
The starting sequence ID can be changed for either mode by using CloudantV1.PostChangesParams.since. By default when using:
In either mode the Stream of changes can be terminated early by calling stop.
By default ChangesFollower will suppress transient errors indefinitely and endeavour to run to completion or listen forever. For applications where that behaviour is not desirable an alternate constructor is available where a errorTolerance may be specified to limit the time since the last successful response that transient errors will be suppressed.
It should be noted that errors considered terminal, for example, the database not existing or invalid credentials are never suppressed and will throw an exception immediately.
The CloudantV1.PostChangesParams model of changes feed options is used to configure the behaviour of the ChangesFollower. However, a subset of the options are invalid as they are configured internally by the implementation and will cause an Error to be thrown if supplied. These invalid options are:
Only the value of
_selector
is permitted for the CloudantV1.PostChangesParams.filter option. Selector based filters perform better than JS based filters and using one of the alternative JS based filter types will cause ChangesFollower to throw an Error.It should also be noted that the CloudantV1.PostChangesParams.limit parameter will truncate the stream at the given number of changes in either operating mode.
The ChangesFollower requires the CloudantV1 client to have HTTP call and read timeouts of at least 1 minute. The default client configuration has sufficiently long timeouts.