117 lines
3.6 KiB
C#
117 lines
3.6 KiB
C#
using System.Configuration;
|
|
using Kreta.Core.MessageBroker.Configuration.IntegratedMessageClient;
|
|
using Validators = Kreta.Core.Configuration.Validators;
|
|
|
|
namespace Kreta.MessageBroker.Configuration
|
|
{
|
|
/// <summary>
|
|
/// Message client configuration element
|
|
/// </summary>
|
|
class MessageClientConfigurationElement : ConfigurationElement, IIntegratedMessageClientConfiguration
|
|
{
|
|
/// <summary>
|
|
/// Element name
|
|
/// </summary>
|
|
public const string ElementName = "Client";
|
|
|
|
/// <summary>
|
|
/// Client name
|
|
/// </summary>
|
|
[ConfigurationProperty(nameof(Name), IsRequired = true, DefaultValue = Validators.StringValidator.SkipValidationForDefaultValue)]
|
|
[Validators.StringValidator(false, MaxLength = 128)]
|
|
public string Name
|
|
{
|
|
get
|
|
{
|
|
return (string)this[nameof(Name)];
|
|
}
|
|
}
|
|
|
|
string IIntegratedMessageClientConfiguration.EndpointClientName => this.Name;
|
|
|
|
/// <summary>
|
|
/// Message signature key
|
|
/// </summary>
|
|
[ConfigurationProperty(nameof(MessageSignatureKey), IsRequired = true, DefaultValue = Validators.StringValidator.SkipValidationForDefaultValue)]
|
|
[Validators.StringValidator(false, MinLength = 32, MaxLength = 128)]
|
|
public string MessageSignatureKey
|
|
{
|
|
get
|
|
{
|
|
return (string)this[nameof(MessageSignatureKey)];
|
|
}
|
|
}
|
|
|
|
[ConfigurationProperty(nameof(QueueSize), DefaultValue = 0)]
|
|
public int QueueSize
|
|
{
|
|
get
|
|
{
|
|
return (int)this[nameof(QueueSize)];
|
|
}
|
|
}
|
|
|
|
[ConfigurationProperty(nameof(ClientPoolSize), DefaultValue = 8)]
|
|
[Validators.IntegerValidator(MinValue = 1)]
|
|
public int ClientPoolSize
|
|
{
|
|
get
|
|
{
|
|
return (int)this[nameof(ClientPoolSize)];
|
|
}
|
|
}
|
|
|
|
[ConfigurationProperty(nameof(CreateNewClientAfterErrorsCount), DefaultValue = 20)]
|
|
[Validators.IntegerValidator(MinValue = 3)]
|
|
public int CreateNewClientAfterErrorsCount
|
|
{
|
|
get
|
|
{
|
|
return (int)this[nameof(CreateNewClientAfterErrorsCount)];
|
|
}
|
|
}
|
|
|
|
int? IIntegratedMessageClientConfiguration.CreateNewClientAfterErrorsCount => this.CreateNewClientAfterErrorsCount == 0 ? (int?)null : this.CreateNewClientAfterErrorsCount;
|
|
|
|
/// <summary>
|
|
/// Enable logging
|
|
/// </summary>
|
|
[ConfigurationProperty(nameof(EnableLogging), IsRequired = true)]
|
|
public bool EnableLogging
|
|
{
|
|
get
|
|
{
|
|
return (bool)this[nameof(EnableLogging)];
|
|
}
|
|
}
|
|
|
|
bool IIntegratedMessageClientConfiguration.IsLoggingEnabled => this.EnableLogging;
|
|
|
|
[ConfigurationProperty(nameof(LoggerType), DefaultValue = LoggerType.Log4Net)]
|
|
public LoggerType LoggerType
|
|
{
|
|
get
|
|
{
|
|
return (LoggerType)this[nameof(LoggerType)];
|
|
}
|
|
}
|
|
|
|
[ConfigurationProperty(nameof(SerilogLogger))]
|
|
public SerilogConfigurationElement SerilogLogger
|
|
{
|
|
get
|
|
{
|
|
return (SerilogConfigurationElement)this[nameof(SerilogLogger)];
|
|
}
|
|
}
|
|
|
|
[ConfigurationProperty(nameof(CalculateBackOffTimeSpan), DefaultValue = true)]
|
|
public bool CalculateBackOffTimeSpan
|
|
{
|
|
get
|
|
{
|
|
return (bool)this[nameof(CalculateBackOffTimeSpan)];
|
|
}
|
|
}
|
|
}
|
|
}
|