public IEnumerable <JsonDocument> Handle(IEnumerable <JsonDocument> docs) { return(docs .Where(document => { var info = docActions.GetRecentTouchesFor(document.Key); if (info != null) { if (info.TouchedEtag.CompareTo(lastEtag) > 0) { if (Log.IsDebugEnabled) { Log.Debug( "Will not replicate document '{0}' to '{1}' because the updates after etag {2} are related document touches", document.Key, destinationId, info.TouchedEtag); } return false; } } string reason; return strategy.FilterDocuments(destinationId, document.Key, document.Metadata, out reason) && prefetchingBehavior.FilterDocuments(document); })); }
public IEnumerable <JsonDocument> Handle(IEnumerable <JsonDocument> docs) { return(docs .Where(document => { string reason; return strategy.FilterDocuments(destinationId, document.Key, document.Metadata, out reason) && prefetchingBehavior.FilterDocuments(document); })); }
private Func <string, RavenJObject, Func <JsonDocument>, bool> WillDocumentBeReplicated( ReplicationStrategy strategy, string destinationId, Action skippedAction = null) { return((key, metadata, getDocument) => { string _; if (strategy.FilterDocuments(destinationId, key, metadata, out _) == false) { skippedAction?.Invoke(); return false; } if (strategy.IsETL == false) { //not ETL replication return true; } var collection = metadata.Value <string>(Constants.RavenEntityName); string script; if (string.IsNullOrEmpty(collection) || strategy.SpecifiedCollections.TryGetValue(collection, out script) == false) { //document has no collection or this collection will not be replicated skippedAction?.Invoke(); return false; } if (string.IsNullOrEmpty(script) || metadata.ContainsKey(Constants.RavenDeleteMarker)) { //no filter script or this document is deleted return true; } if (WillReplicateByScript(script, getDocument()) == false) { skippedAction?.Invoke(); return false; } return true; }); }