2019-04-24 16:04:30 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
2022-11-23 08:13:38 +00:00
|
|
|
|
using System.Linq;
|
2019-04-24 16:04:30 +00:00
|
|
|
|
using Tapeti.Config;
|
|
|
|
|
|
|
|
|
|
namespace Tapeti.Transient
|
|
|
|
|
{
|
2019-08-13 18:30:04 +00:00
|
|
|
|
/// <inheritdoc cref="ITapetiExtension" />
|
|
|
|
|
public class TransientExtension : ITapetiExtensionBinding
|
2019-04-24 16:04:30 +00:00
|
|
|
|
{
|
2019-08-13 18:30:04 +00:00
|
|
|
|
private readonly string dynamicQueuePrefix;
|
2019-04-25 13:19:51 +00:00
|
|
|
|
private readonly TransientRouter router;
|
2019-04-24 16:04:30 +00:00
|
|
|
|
|
2019-08-13 18:30:04 +00:00
|
|
|
|
|
2021-05-29 19:51:58 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// </summary>
|
2019-08-13 18:30:04 +00:00
|
|
|
|
public TransientExtension(TimeSpan defaultTimeout, string dynamicQueuePrefix)
|
2019-04-24 16:04:30 +00:00
|
|
|
|
{
|
|
|
|
|
this.dynamicQueuePrefix = dynamicQueuePrefix;
|
2019-08-13 18:30:04 +00:00
|
|
|
|
router = new TransientRouter(defaultTimeout);
|
2019-04-24 16:04:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-08-13 18:30:04 +00:00
|
|
|
|
|
|
|
|
|
/// <inheritdoc />
|
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>();
|
|
|
|
|
}
|
|
|
|
|
|
2019-08-13 18:30:04 +00:00
|
|
|
|
|
|
|
|
|
/// <inheritdoc />
|
2019-04-24 16:04:30 +00:00
|
|
|
|
public IEnumerable<object> GetMiddleware(IDependencyResolver dependencyResolver)
|
|
|
|
|
{
|
2022-11-23 08:13:38 +00:00
|
|
|
|
return Enumerable.Empty<object>();
|
2019-04-24 16:04:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-08-13 18:30:04 +00:00
|
|
|
|
|
|
|
|
|
/// <inheritdoc />
|
|
|
|
|
public IEnumerable<IBinding> GetBindings(IDependencyResolver dependencyResolver)
|
2019-04-24 16:04:30 +00:00
|
|
|
|
{
|
2019-04-25 13:19:51 +00:00
|
|
|
|
yield return new TransientGenericBinding(router, dynamicQueuePrefix);
|
2019-04-24 16:04:30 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|