44
55namespace Nest
66{
7+ /// <summary> Ingest pipelines are composed of one or more processors </summary>
78 public interface IProcessor
89 {
10+ // TODO: even though this property is ignored it has a JsonProperty because our GetCachedProperties helper prefers
11+ // this property over the differently named subclass property that has JsonProperty("name"). Needs fixing outside the
12+ // scope of the current branch and warrants deeper investigation. Hence the current hack of __ignored__
13+ /// <summary> The name of the processor, will be used as the key when persisting the processor on the pipeline </summary>
14+ [ JsonIgnore , JsonProperty ( "__ignored__" ) ]
915 string Name { get ; }
1016
17+ /// <summary>
18+ /// If a processor fails, call these processors instead. Read more about handling failures here:
19+ /// https://www.elastic.co/guide/en/elasticsearch/reference/current/handling-failure-in-pipelines.html
20+ /// </summary>
1121 [ JsonProperty ( "on_failure" ) ]
1222 IEnumerable < IProcessor > OnFailure { get ; set ; }
23+
24+ /// <summary> A painless script predicate that can control whether this processor should be executed or not </summary>
25+ [ JsonProperty ( "if" ) ]
26+ string If { get ; set ; }
27+
28+ /// <summary>
29+ /// A tag is simply a string identifier of the specific instantiation of a certain processor
30+ /// in a pipeline. The tag field does not affect the processor’s behavior, but is very useful
31+ /// for bookkeeping and tracing errors to specific processors.
32+ /// </summary>
33+ [ JsonProperty ( "tag" ) ]
34+ string Tag { get ; set ; }
35+
36+ /// <summary> When a failure happens, ignore it and proceed to the next processor </summary>
37+ [ JsonProperty ( "ignore_failue" ) ]
38+ bool ? IgnoreFailure { get ; set ; }
1339 }
1440
41+ /// <inheritdoc cref="IProcessor"/>
1542 public abstract class ProcessorBase : IProcessor
1643 {
44+ /// <inheritdoc cref="IProcessor.If"/>
45+ public string If { get ; set ; }
46+ /// <inheritdoc cref="IProcessor.Tag"/>
47+ public string Tag { get ; set ; }
48+ /// <inheritdoc cref="IProcessor.IgnoreFailure"/>
49+ public bool ? IgnoreFailure { get ; set ; }
50+ /// <inheritdoc cref="IProcessor.OnFailure"/>
1751 public IEnumerable < IProcessor > OnFailure { get ; set ; }
1852 protected abstract string Name { get ; }
1953 string IProcessor . Name => Name ;
2054 }
2155
56+ /// <inheritdoc cref="IProcessor"/>
2257 public abstract class ProcessorDescriptorBase < TProcessorDescriptor , TProcessorInterface >
2358 : DescriptorBase < TProcessorDescriptor , TProcessorInterface > , IProcessor
2459 where TProcessorDescriptor : ProcessorDescriptorBase < TProcessorDescriptor , TProcessorInterface > , TProcessorInterface
@@ -27,12 +62,26 @@ public abstract class ProcessorDescriptorBase<TProcessorDescriptor, TProcessorIn
2762 protected abstract string Name { get ; }
2863 string IProcessor . Name => Name ;
2964 IEnumerable < IProcessor > IProcessor . OnFailure { get ; set ; }
65+ string IProcessor . If { get ; set ; }
66+ string IProcessor . Tag { get ; set ; }
67+ bool ? IProcessor . IgnoreFailure { get ; set ; }
3068
31- /// <inheritdoc />
69+ /// <inheritdoc cref="IProcessor.OnFailure" />
3270 public TProcessorDescriptor OnFailure ( IEnumerable < IProcessor > processors ) => Assign ( a => a . OnFailure = processors . ToListOrNullIfEmpty ( ) ) ;
3371
34- /// <inheritdoc />
72+ /// <inheritdoc cref="IProcessor.OnFailure" />
3573 public TProcessorDescriptor OnFailure ( Func < ProcessorsDescriptor , IPromise < IList < IProcessor > > > selector ) =>
3674 Assign ( a => a . OnFailure = selector ? . Invoke ( new ProcessorsDescriptor ( ) ) ? . Value ) ;
75+
76+ /// <inheritdoc cref="IProcessor.If"/>
77+ public TProcessorDescriptor If ( string painlessPredicate ) => Assign ( a => a . If = painlessPredicate ) ;
78+
79+ /// <inheritdoc cref="IProcessor.Tag"/>
80+ public TProcessorDescriptor Tag ( string tag ) => Assign ( a => a . Tag = tag ) ;
81+
82+ /// <inheritdoc cref="IProcessor.IgnoreFailure"/>
83+ public TProcessorDescriptor IgnoreFailure ( bool ? ignoreFailure = true ) => Assign ( a => a . IgnoreFailure = ignoreFailure ) ;
84+
3785 }
86+
3887}
0 commit comments