2016-12-05 07:00:09 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
2016-11-20 13:34:50 +00:00
|
|
|
|
using System.Linq;
|
2016-11-17 16:33:27 +00:00
|
|
|
|
using System.Threading.Tasks;
|
2016-11-16 22:11:05 +00:00
|
|
|
|
|
|
|
|
|
namespace Tapeti.Connection
|
|
|
|
|
{
|
|
|
|
|
public class TapetiSubscriber : ISubscriber
|
|
|
|
|
{
|
2016-12-05 07:00:09 +00:00
|
|
|
|
private readonly Func<TapetiWorker> workerFactory;
|
2016-11-16 22:11:05 +00:00
|
|
|
|
|
|
|
|
|
|
2016-12-05 07:00:09 +00:00
|
|
|
|
public TapetiSubscriber(Func<TapetiWorker> workerFactory)
|
2016-11-16 22:11:05 +00:00
|
|
|
|
{
|
2016-12-05 07:00:09 +00:00
|
|
|
|
this.workerFactory = workerFactory;
|
2016-11-16 22:11:05 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2016-11-20 13:34:50 +00:00
|
|
|
|
public async Task BindQueues(IEnumerable<IQueueRegistration> registrations)
|
2016-11-16 22:11:05 +00:00
|
|
|
|
{
|
2016-12-05 07:00:09 +00:00
|
|
|
|
await Task.WhenAll(registrations.Select(registration => workerFactory().Subscribe(registration)).ToList());
|
2016-11-16 22:11:05 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|