Used by BLIP connections for changes. Supports both one-shot and continuous changes. Returns an error in the case that the feed does not start up, or there is a fatal error in the feed. The caller is responsible for closing the connection, no more changes will be generated. forceClose will be true
(ctx context.Context, database *DatabaseCollectionWithUser, inChannels base.Set, options ChangesOptions, docIDFilter []string, send func([]*ChangeEntry) error)
| 1482 | |
| 1483 | // Used by BLIP connections for changes. Supports both one-shot and continuous changes. Returns an error in the case that the feed does not start up, or there is a fatal error in the feed. The caller is responsible for closing the connection, no more changes will be generated. forceClose will be true if connection was terminated underneath the changes feed. |
| 1484 | func generateBlipSyncChanges(ctx context.Context, database *DatabaseCollectionWithUser, inChannels base.Set, options ChangesOptions, docIDFilter []string, send func([]*ChangeEntry) error) (forceClose bool, err error) { |
| 1485 | |
| 1486 | // Store one-shot here to protect |
| 1487 | isOneShot := !options.Continuous |
| 1488 | err, forceClose = GenerateChanges(ctx, database, inChannels, options, docIDFilter, send) |
| 1489 | |
| 1490 | if _, ok := err.(*ChangesSendErr); ok { |
| 1491 | // If there was already an error in a send function, do not send last one shot changes message, since it probably will not work anyway. |
| 1492 | return forceClose, err // error is probably because the client closed the connection |
| 1493 | } |
| 1494 | |
| 1495 | // For one-shot changes, invoke the callback w/ nil to trigger the 'caught up' changes message. (For continuous changes, this |
| 1496 | // is done by MultiChangesFeed prior to going into Wait mode) |
| 1497 | if isOneShot { |
| 1498 | _ = send(nil) |
| 1499 | } |
| 1500 | return forceClose, err |
| 1501 | } |
| 1502 | |
| 1503 | type ChangesSendErr struct{ error } |
| 1504 |
no test coverage detected