| | | 1 | | // Copyright (c) ZeroC, Inc. |
| | | 2 | | |
| | | 3 | | using IceRpc.Deadline; |
| | | 4 | | |
| | | 5 | | namespace IceRpc; |
| | | 6 | | |
| | | 7 | | /// <summary>Provides extension methods for <see cref="Pipeline" /> to add the deadline interceptor.</summary> |
| | | 8 | | public static class DeadlinePipelineExtensions |
| | | 9 | | { |
| | | 10 | | /// <summary>Adds a <see cref="DeadlineInterceptor" /> with an infinite default timeout to this pipeline. |
| | | 11 | | /// This interceptor enforces the deadlines it receives and does not create new deadlines.</summary> |
| | | 12 | | /// <param name="pipeline">The pipeline being configured.</param> |
| | | 13 | | /// <returns>The pipeline being configured.</returns> |
| | | 14 | | /// <example> |
| | | 15 | | /// The following code adds the deadline interceptor to the invocation pipeline. |
| | | 16 | | /// <code source="../../docfx/examples/IceRpc.Deadline.Examples/DeadlineInterceptorExamples.cs" region="UseDeadline" |
| | | 17 | | /// </example> |
| | 0 | 18 | | public static Pipeline UseDeadline(this Pipeline pipeline) => pipeline.UseDeadline(Timeout.InfiniteTimeSpan); |
| | | 19 | | |
| | | 20 | | /// <summary>Adds a <see cref="DeadlineInterceptor" /> to this pipeline.</summary> |
| | | 21 | | /// <param name="pipeline">The pipeline being configured.</param> |
| | | 22 | | /// <param name="defaultTimeout">The default timeout. When not infinite, the interceptor adds a deadline to requests |
| | | 23 | | /// without a deadline.</param> |
| | | 24 | | /// <param name="alwaysEnforceDeadline">When <see langword="true" /> and the request carries a deadline, the |
| | | 25 | | /// interceptor always creates a cancellation token source to enforce this deadline. When <see langword="false" /> |
| | | 26 | | /// and the request carries a deadline, the interceptor creates a cancellation token source to enforce this deadline |
| | | 27 | | /// only when the invocation's cancellation token cannot be canceled. The default value is <see langword="false" />. |
| | | 28 | | /// </param> |
| | | 29 | | /// <returns>The pipeline being configured.</returns> |
| | | 30 | | /// <example> |
| | | 31 | | /// The following code adds the deadline interceptor to the invocation pipeline. |
| | | 32 | | /// <code source="../../docfx/examples/IceRpc.Deadline.Examples/DeadlineInterceptorExamples.cs" region="UseDeadlineW |
| | | 33 | | /// </example> |
| | | 34 | | public static Pipeline UseDeadline( |
| | | 35 | | this Pipeline pipeline, |
| | | 36 | | TimeSpan defaultTimeout, |
| | | 37 | | bool alwaysEnforceDeadline = false) => |
| | 0 | 38 | | pipeline.Use(next => new DeadlineInterceptor(next, defaultTimeout, alwaysEnforceDeadline)); |
| | | 39 | | } |