2019-04-24 16:04:30 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using Tapeti.Config;
|
|
|
|
|
|
|
|
|
|
namespace Tapeti.Transient
|
|
|
|
|
{
|
|
|
|
|
public class TransientMiddleware : ITapetiExtension, ITapetiExtentionBinding
|
|
|
|
|
{
|
|
|
|
|
private string dynamicQueuePrefix;
|
2019-04-25 13:19:51 +00:00
|
|
|
|
private readonly TransientRouter router;
|
2019-04-24 16:04:30 +00:00
|
|
|
|
|
|
|
|
|
public TransientMiddleware(TimeSpan defaultTimeout, string dynamicQueuePrefix)
|
|
|
|
|
{
|
|
|
|
|
this.dynamicQueuePrefix = dynamicQueuePrefix;
|
2019-04-25 13:19:51 +00:00
|
|
|
|
this.router = new TransientRouter(defaultTimeout);
|
2019-04-24 16:04:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void RegisterDefaults(IDependencyContainer container)
|
|
|
|
|
{
|
2019-04-25 13:19:51 +00:00
|
|
|
|
container.RegisterDefaultSingleton(router);
|
2019-04-24 16:04:30 +00:00
|
|
|
|
container.RegisterDefault<ITransientPublisher, TransientPublisher>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IEnumerable<object> GetMiddleware(IDependencyResolver dependencyResolver)
|
|
|
|
|
{
|
|
|
|
|
return new object[0];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IEnumerable<ICustomBinding> GetBindings(IDependencyResolver dependencyResolver)
|
|
|
|
|
{
|
2019-04-25 13:19:51 +00:00
|
|
|
|
yield return new TransientGenericBinding(router, dynamicQueuePrefix);
|
2019-04-24 16:04:30 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|