2019-04-24 18:04:30 +02:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
2022-11-23 09:13:38 +01:00
|
|
|
|
using System.Linq;
|
2019-04-24 18:04:30 +02:00
|
|
|
|
using Tapeti.Config;
|
|
|
|
|
|
|
|
|
|
namespace Tapeti.Transient
|
|
|
|
|
{
|
2019-08-13 20:30:04 +02:00
|
|
|
|
/// <inheritdoc cref="ITapetiExtension" />
|
|
|
|
|
public class TransientExtension : ITapetiExtensionBinding
|
2019-04-24 18:04:30 +02:00
|
|
|
|
{
|
2019-08-13 20:30:04 +02:00
|
|
|
|
private readonly string dynamicQueuePrefix;
|
2019-04-25 15:19:51 +02:00
|
|
|
|
private readonly TransientRouter router;
|
2019-04-24 18:04:30 +02:00
|
|
|
|
|
2019-08-13 20:30:04 +02:00
|
|
|
|
|
2021-05-29 21:51:58 +02:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// </summary>
|
2019-08-13 20:30:04 +02:00
|
|
|
|
public TransientExtension(TimeSpan defaultTimeout, string dynamicQueuePrefix)
|
2019-04-24 18:04:30 +02:00
|
|
|
|
{
|
|
|
|
|
this.dynamicQueuePrefix = dynamicQueuePrefix;
|
2019-08-13 20:30:04 +02:00
|
|
|
|
router = new TransientRouter(defaultTimeout);
|
2019-04-24 18:04:30 +02:00
|
|
|
|
}
|
|
|
|
|
|
2019-08-13 20:30:04 +02:00
|
|
|
|
|
|
|
|
|
/// <inheritdoc />
|
2019-04-24 18:04:30 +02:00
|
|
|
|
public void RegisterDefaults(IDependencyContainer container)
|
|
|
|
|
{
|
2019-04-25 15:19:51 +02:00
|
|
|
|
container.RegisterDefaultSingleton(router);
|
2019-04-24 18:04:30 +02:00
|
|
|
|
container.RegisterDefault<ITransientPublisher, TransientPublisher>();
|
|
|
|
|
}
|
|
|
|
|
|
2019-08-13 20:30:04 +02:00
|
|
|
|
|
|
|
|
|
/// <inheritdoc />
|
2019-04-24 18:04:30 +02:00
|
|
|
|
public IEnumerable<object> GetMiddleware(IDependencyResolver dependencyResolver)
|
|
|
|
|
{
|
2022-11-23 09:13:38 +01:00
|
|
|
|
return Enumerable.Empty<object>();
|
2019-04-24 18:04:30 +02:00
|
|
|
|
}
|
|
|
|
|
|
2019-08-13 20:30:04 +02:00
|
|
|
|
|
|
|
|
|
/// <inheritdoc />
|
|
|
|
|
public IEnumerable<IBinding> GetBindings(IDependencyResolver dependencyResolver)
|
2019-04-24 18:04:30 +02:00
|
|
|
|
{
|
2019-04-25 15:19:51 +02:00
|
|
|
|
yield return new TransientGenericBinding(router, dynamicQueuePrefix);
|
2019-04-24 18:04:30 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|