Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class ConsumerTimeoutFilter<T> : IFilter<T> where T : class, PipeContext
- {
- private readonly TimeSpan timeout;
- public ConsumerTimeoutFilter(TimeSpan timeout)
- {
- this.timeout = timeout;
- }
- public Task Send(T context, IPipe<T> next)
- {
- var source = new CancellationTokenSource();
- var task = Task.Run(() => next.Send(context), source.Token);
- source.CancelAfter(timeout);
- return task;
- }
- public void Probe(ProbeContext context)
- {
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement