فهرست منبع

Add default implementations for configurations

Olivier Coanet 4 سال پیش
والد
کامیت
03c5b71876

+ 7 - 8
src/Abc.Zebus.Tests/Core/BusManualTests.cs

@@ -82,16 +82,15 @@ namespace Abc.Zebus.Tests.Core
         [Test]
         public void should_generate_unacked_messages()
         {
-            var targetConfig = new Mock<IBusConfiguration>();
-            targetConfig.SetupGet(x => x.DirectoryServiceEndPoints).Returns(new[] { _directoryEndPoint });
-            targetConfig.SetupGet(x => x.IsPersistent).Returns(true);
-            targetConfig.SetupGet(x => x.RegistrationTimeout).Returns(30.Seconds());
-            targetConfig.SetupGet(x => x.StartReplayTimeout).Returns(30.Seconds());
+            var targetConfig = new BusConfiguration(_directoryEndPoint)
+            {
+                IsPersistent = true,
+            };
 
             var target = CreateBusFactory().WithHandlers(typeof(ManualEventHandler))
-                                                  .WithConfiguration(targetConfig.Object, "Demo")
-                                                  .WithPeerId("Some.Random.Persistent.Peer.0")
-                                                  .CreateAndStartBus();
+                                           .WithConfiguration(targetConfig, "Demo")
+                                           .WithPeerId("Some.Random.Persistent.Peer.0")
+                                           .CreateAndStartBus();
             using (var source = CreateBusFactory().CreateAndStartBus())
             {
                 source.Publish(new ManualEvent(42));

+ 10 - 16
src/Abc.Zebus.Tests/Core/BusPerformanceTests.cs

@@ -161,7 +161,7 @@ namespace Abc.Zebus.Tests.Core
         {
             return new BusFactory()
                 .WithPeerId("Abc.Zebus.Perf.Sender.*")
-                .WithConfiguration(new BusConfiguration(false, _directoryEndPoint), "Dev")
+                .WithConfiguration(CreateBusConfiguration(false, _directoryEndPoint), "Dev")
                 .ConfigureContainer(x => x.For<ZmqSocketOptions>().Use(new ZmqSocketOptions { SendHighWaterMark = 100000, SendTimeout = 10.Second() }))
                 .CreateAndStartBus();
         }
@@ -170,28 +170,22 @@ namespace Abc.Zebus.Tests.Core
         {
             return new BusFactory()
                 .WithPeerId("Abc.Zebus.Perf.Receiver.*")
-                .WithConfiguration(new BusConfiguration(isPersistent, _directoryEndPoint), "Dev")
+                .WithConfiguration(CreateBusConfiguration(isPersistent, _directoryEndPoint), "Dev")
                 .WithHandlers(typeof(PerfHandler))
                 .ConfigureContainer(x => x.For<ZmqSocketOptions>().Use(new ZmqSocketOptions { ReceiveHighWaterMark = 100000 }))
                 .CreateAndStartBus();
         }
 
-        private class BusConfiguration : IBusConfiguration
+        private static IBusConfiguration CreateBusConfiguration(bool isPersistent, string directoryServiceEndPoint)
         {
-            public BusConfiguration(bool isPersistent, string directoryServiceEndPoint)
+            return new BusConfiguration(directoryServiceEndPoint)
             {
-                DirectoryServiceEndPoints = new[] { directoryServiceEndPoint };
-                RegistrationTimeout = 10.Second();
-                IsPersistent = isPersistent;
-            }
-
-            public string[] DirectoryServiceEndPoints { get; }
-            public TimeSpan RegistrationTimeout { get; }
-            public TimeSpan StartReplayTimeout => 30.Seconds();
-            public bool IsPersistent { get; }
-            public bool IsDirectoryPickedRandomly => false;
-            public bool IsErrorPublicationEnabled => false;
-            public int MessagesBatchSize => 200;
+                IsPersistent = isPersistent,
+                RegistrationTimeout = 10.Seconds(),
+                StartReplayTimeout = 30.Seconds(),
+                IsDirectoryPickedRandomly = false,
+                IsErrorPublicationEnabled = false,
+            };
         }
 
         [ProtoContract]

+ 1 - 1
src/Abc.Zebus.Tests/Core/BusTests.Core.cs

@@ -26,7 +26,7 @@ namespace Abc.Zebus.Tests.Core
             {
                 var transportMock = new Mock<ITransport>();
                 var messageDispatcher = new Mock<IMessageDispatcher>();
-                var bus = new Bus(transportMock.Object, new Mock<IPeerDirectory>().Object, null, messageDispatcher.Object, new DefaultMessageSendingStrategy(), new DefaultStoppingStrategy(), _configuration.Object);
+                var bus = new Bus(transportMock.Object, new Mock<IPeerDirectory>().Object, null, messageDispatcher.Object, new DefaultMessageSendingStrategy(), new DefaultStoppingStrategy(), _configuration);
 
                 bus.Configure(_self.Id, _environment);
 

+ 3 - 3
src/Abc.Zebus.Tests/Core/BusTests.DeserializationErrors.cs

@@ -21,7 +21,7 @@ namespace Abc.Zebus.Tests.Core
                 base.Setup();
 
                 _bus.DeserializationFailureDumpDirectoryPath = PathUtil.InBaseDirectory(Guid.NewGuid().ToString().Substring(0, 4));
-                _configuration.SetupGet(x => x.IsErrorPublicationEnabled).Returns(true);
+                _configuration.IsErrorPublicationEnabled = true;
             }
 
             [Test]
@@ -58,7 +58,7 @@ namespace Abc.Zebus.Tests.Core
             [Test]
             public void should_send_MessageProcessingFailed_when_error_publication_os_not_enabled()
             {
-                _configuration.SetupGet(x => x.IsErrorPublicationEnabled).Returns(false);
+                _configuration.IsErrorPublicationEnabled = false;
 
                 SetupPeersHandlingMessage<MessageProcessingFailed>(_peerUp);
 
@@ -131,4 +131,4 @@ namespace Abc.Zebus.Tests.Core
             }
         }
     }
-}
+}

+ 1 - 1
src/Abc.Zebus.Tests/Core/BusTests.Dispatch.cs

@@ -216,7 +216,7 @@ namespace Abc.Zebus.Tests.Core
             public void should_stop_dispatcher_before_transport()
             {
                 var transportMock = new Mock<ITransport>();
-                var bus = new Bus(transportMock.Object, _directoryMock.Object, _messageSerializer, _messageDispatcherMock.Object, new DefaultMessageSendingStrategy(), new DefaultStoppingStrategy(), _configuration.Object);
+                var bus = new Bus(transportMock.Object, _directoryMock.Object, _messageSerializer, _messageDispatcherMock.Object, new DefaultMessageSendingStrategy(), new DefaultStoppingStrategy(), _configuration);
                 var sequence = new SetupSequence();
                 _messageDispatcherMock.Setup(dispatch => dispatch.Stop()).InSequence(sequence);
                 transportMock.Setup(transport => transport.Stop()).InSequence(sequence);

+ 2 - 2
src/Abc.Zebus.Tests/Core/BusTests.DispatchErrors.cs

@@ -21,7 +21,7 @@ namespace Abc.Zebus.Tests.Core
             {
                 base.Setup();
 
-                _configuration.SetupGet(x => x.IsErrorPublicationEnabled).Returns(true);
+                _configuration.IsErrorPublicationEnabled = true;
             }
 
             [Test]
@@ -99,7 +99,7 @@ namespace Abc.Zebus.Tests.Core
             [Test]
             public void should_not_send_a_MessageProcessingFailed_when_error_publication_is_not_enabled()
             {
-                _configuration.SetupGet(x => x.IsErrorPublicationEnabled).Returns(false);
+                _configuration.IsErrorPublicationEnabled = false;
 
                 SetupPeersHandlingMessage<MessageProcessingFailed>(_peerUp);
 

+ 3 - 4
src/Abc.Zebus.Tests/Core/BusTests.cs

@@ -3,7 +3,6 @@ using System.Collections.Generic;
 using Abc.Zebus.Core;
 using Abc.Zebus.Directory;
 using Abc.Zebus.Dispatch;
-using Abc.Zebus.Routing;
 using Abc.Zebus.Testing.Comparison;
 using Abc.Zebus.Testing.Dispatch;
 using Abc.Zebus.Testing.Transport;
@@ -23,7 +22,7 @@ namespace Abc.Zebus.Tests.Core
         private readonly Peer _peerDown = new Peer(new PeerId("Abc.Testing.Down"), "tcp://abctest:999", false);
 
         private Bus _bus;
-        private Mock<IBusConfiguration> _configuration;
+        private BusConfiguration _configuration;
         private TestTransport _transport;
         private Mock<IPeerDirectory> _directoryMock;
         private Mock<IMessageDispatcher> _messageDispatcherMock;
@@ -33,13 +32,13 @@ namespace Abc.Zebus.Tests.Core
         [SetUp]
         public virtual void Setup()
         {
-            _configuration = new Mock<IBusConfiguration>();
+            _configuration = new BusConfiguration("tcp://zebus-directory:123");
             _transport = new TestTransport(_self.EndPoint);
             _directoryMock = new Mock<IPeerDirectory>();
             _messageDispatcherMock = new Mock<IMessageDispatcher>();
             _messageSerializer = new TestMessageSerializer();
 
-            _bus = new Bus(_transport, _directoryMock.Object, _messageSerializer, _messageDispatcherMock.Object, new DefaultMessageSendingStrategy(), new DefaultStoppingStrategy(), _configuration.Object);
+            _bus = new Bus(_transport, _directoryMock.Object, _messageSerializer, _messageDispatcherMock.Object, new DefaultMessageSendingStrategy(), new DefaultStoppingStrategy(), _configuration);
             _bus.Configure(_self.Id, _environment);
 
             _invokers = new List<IMessageHandlerInvoker>();

+ 2 - 2
src/Abc.Zebus.Tests/Directory/PeerDirectoryClientTests.Performance.cs

@@ -28,7 +28,7 @@ namespace Abc.Zebus.Tests.Directory
 
             var subscriptionsByTypeId = subscriptions.GroupBy(x => x.MessageTypeId).ToDictionary(x => x.Key, x => x.Select(s=>s.BindingKey).ToArray());
 
-            _directory = new PeerDirectoryClient(_configurationMock.Object);
+            _directory = new PeerDirectoryClient(_configuration);
             _directory.Handle(new PeerStarted(_otherPeer.ToPeerDescriptor(false)));
 
             Console.WriteLine("Snapshot updates (add)");
@@ -48,7 +48,7 @@ namespace Abc.Zebus.Tests.Directory
                 }
             }
 
-            _directory = new PeerDirectoryClient(_configurationMock.Object);
+            _directory = new PeerDirectoryClient(_configuration);
             _directory.Handle(new PeerStarted(_otherPeer.ToPeerDescriptor(false)));
 
             Console.WriteLine("Snapshot updates per message type id (add)");

+ 11 - 9
src/Abc.Zebus.Tests/Directory/PeerDirectoryClientTests.cs

@@ -3,6 +3,7 @@ using System.Collections.Generic;
 using System.Linq;
 using System.Threading;
 using System.Threading.Tasks;
+using Abc.Zebus.Core;
 using Abc.Zebus.Directory;
 using Abc.Zebus.Routing;
 using Abc.Zebus.Testing;
@@ -22,7 +23,7 @@ namespace Abc.Zebus.Tests.Directory
     public partial class PeerDirectoryClientTests
     {
         private PeerDirectoryClient _directory;
-        private Mock<IBusConfiguration> _configurationMock;
+        private BusConfiguration _configuration;
         private TestBus _bus;
         private Peer _self;
         private Peer _otherPeer;
@@ -30,12 +31,13 @@ namespace Abc.Zebus.Tests.Directory
         [SetUp]
         public void Setup()
         {
-            _configurationMock = new Mock<IBusConfiguration>();
-            _configurationMock.SetupGet(x => x.DirectoryServiceEndPoints).Returns(new[] { "tcp://main-directory:777", "tcp://backup-directory:777" });
-            _configurationMock.SetupGet(x => x.RegistrationTimeout).Returns(500.Milliseconds());
-            _configurationMock.SetupGet(x => x.IsDirectoryPickedRandomly).Returns(false);
+            _configuration = new BusConfiguration(new[] { "tcp://main-directory:777", "tcp://backup-directory:777" })
+            {
+                RegistrationTimeout = 500.Milliseconds(),
+                IsDirectoryPickedRandomly = false,
+            };
 
-            _directory = new PeerDirectoryClient(_configurationMock.Object);
+            _directory = new PeerDirectoryClient(_configuration);
             _bus = new TestBus();
             _self = new Peer(new PeerId("Abc.Testing.0"), "tcp://abctest:123");
             _otherPeer = new Peer(new PeerId("Abc.Testing.1"), "tcp://abctest:789");
@@ -47,7 +49,7 @@ namespace Abc.Zebus.Tests.Directory
         public async Task should_register_peer([Values(true, false)] bool isPersistent)
         {
             var subscriptions = TestDataBuilder.CreateSubscriptions<FakeCommand>();
-            _configurationMock.SetupGet(x => x.IsPersistent).Returns(isPersistent);
+            _configuration.IsPersistent = isPersistent;
             _bus.AddHandler<RegisterPeerCommand>(x => new RegisterPeerResponse(new PeerDescriptor[0]));
 
             using (SystemDateTime.PauseTime())
@@ -99,7 +101,7 @@ namespace Abc.Zebus.Tests.Directory
         public void should_not_register_existing_peer()
         {
             var subscriptions = TestDataBuilder.CreateSubscriptions<FakeCommand>();
-            _configurationMock.SetupGet(x => x.IsPersistent).Returns(true);
+            _configuration.IsPersistent = true;
             _bus.AddHandler<RegisterPeerCommand>(_ => throw new MessageProcessingException("Peer already exists") { ErrorCode = DirectoryErrorCodes.PeerAlreadyExists });
 
             using (SystemDateTime.PauseTime())
@@ -493,7 +495,7 @@ namespace Abc.Zebus.Tests.Directory
         [Test]
         public void should_order_directory_peers_randomly()
         {
-            _configurationMock.SetupGet(x => x.IsDirectoryPickedRandomly).Returns(true);
+            _configuration.IsDirectoryPickedRandomly = true;
 
             for (var i = 0; i < 100; i++)
             {

+ 6 - 6
src/Abc.Zebus.Tests/Dispatch/SyncMessageHandlerInvokerTests.cs

@@ -56,12 +56,12 @@ namespace Abc.Zebus.Tests.Dispatch
         public void should_proxy_bus_with_message_context_aware_bus()
         {
             var busMock = new Mock<IBus>();
-            var configurationMock = new Mock<IBusConfiguration>();
+            var configuration = new BusConfiguration("tcp://zebus-directory:123");
             var equalityComparer = StringComparer.OrdinalIgnoreCase;
             var container = new Container(x =>
             {
                 x.ForSingletonOf<IBus>().Use(busMock.Object);
-                x.ForSingletonOf<IBusConfiguration>().Use(configurationMock.Object);
+                x.ForSingletonOf<IBusConfiguration>().Use(configuration);
                 x.For<IEqualityComparer<string>>().Use(equalityComparer);
             });
 
@@ -70,7 +70,7 @@ namespace Abc.Zebus.Tests.Dispatch
 
             var handler = (CommandHandlerWithThreeConstructorArguments)invoker.CreateHandler(messageContext);
             handler.Bus.ShouldNotEqual(busMock.Object);
-            handler.Configuration.ShouldEqual(configurationMock.Object);
+            handler.Configuration.ShouldEqual(configuration);
             handler.EqualityComparerFunc().ShouldEqual(equalityComparer);
 
             var bus = handler.Bus.ShouldBe<MessageContextAwareBus>();
@@ -118,12 +118,12 @@ namespace Abc.Zebus.Tests.Dispatch
         public void MeasureHandlerCreationPerformances()
         {
             var busMock = new Mock<IBus>();
-            var configurationMock = new Mock<IBusConfiguration>();
+            var configuration = new BusConfiguration("tcp://zebus-directory:123");
             var equalityComparer = StringComparer.OrdinalIgnoreCase;
             var container = new Container(x =>
             {
                 x.ForSingletonOf<IBus>().Use(busMock.Object);
-                x.ForSingletonOf<IBusConfiguration>().Use(configurationMock.Object);
+                x.ForSingletonOf<IBusConfiguration>().Use(configuration);
                 x.For<IEqualityComparer<string>>().Use(equalityComparer);
             });
 
@@ -229,4 +229,4 @@ namespace Abc.Zebus.Tests.Dispatch
             }
         }
     }
-}
+}

+ 7 - 10
src/Abc.Zebus.Tests/Initialization/ZebusRegistryTests.cs

@@ -1,6 +1,6 @@
-using Abc.Zebus.Initialization;
+using Abc.Zebus.Core;
+using Abc.Zebus.Initialization;
 using Abc.Zebus.Transport;
-using Moq;
 using NUnit.Framework;
 using StructureMap;
 
@@ -12,20 +12,17 @@ namespace Abc.Zebus.Tests.Initialization
         [Test]
         public void should_have_valid_configuration()
         {
-            var busConfigurationMock = new Mock<IBusConfiguration>();
-            busConfigurationMock.SetupAllProperties();
-
-            var transportConfigurationMock = new Mock<IZmqTransportConfiguration>();
-            transportConfigurationMock.SetupAllProperties();
+            var busConfiguration = new BusConfiguration(new[] { "tcp://zebus-directory:123" });
+            var transportConfiguration = new ZmqTransportConfiguration();
 
             var container = new Container(cfg =>
             {
-                cfg.For<IBusConfiguration>().Use(busConfigurationMock.Object);
-                cfg.For<IZmqTransportConfiguration>().Use(transportConfigurationMock.Object);
+                cfg.For<IBusConfiguration>().Use(busConfiguration);
+                cfg.For<IZmqTransportConfiguration>().Use(transportConfiguration);
                 cfg.AddRegistry<ZebusRegistry>();
             });
 
             container.AssertConfigurationIsValid();
         }
     }
-}
+}

+ 8 - 5
src/Abc.Zebus.Tests/Persistence/PersistentTransportFixture.cs

@@ -11,6 +11,7 @@ using Abc.Zebus.Testing.Extensions;
 using Abc.Zebus.Testing.Transport;
 using Abc.Zebus.Tests.Messages;
 using Abc.Zebus.Transport;
+using Abc.Zebus.Util;
 using Moq;
 using NUnit.Framework;
 
@@ -39,9 +40,11 @@ namespace Abc.Zebus.Tests.Persistence
         {
             InnerTransport = new TestTransport(Self.EndPoint);
 
-            var configuration = new Mock<IBusConfiguration>();
-            configuration.Setup(x => x.IsPersistent).Returns(IsPersistent);
-            configuration.Setup(x => x.StartReplayTimeout).Returns(TimeSpan.FromMinutes(60));
+            var configuration = new BusConfiguration("tcp://zebus-directory:123")
+            {
+                IsPersistent = IsPersistent,
+                StartReplayTimeout = 60.Minutes(),
+            };
 
             PeerDirectory = new Mock<IPeerDirectory>();
             PeerDirectory.Setup(dir => dir.GetPeersHandlingMessage(MessageBinding.Default<PersistMessageCommand>())).Returns(new[] { PersistencePeer });
@@ -51,7 +54,7 @@ namespace Abc.Zebus.Tests.Persistence
             PeerDirectory.Setup(dir => dir.IsPersistent(AnotherPersistentPeer.Id)).Returns(true);
             PeerDirectory.Setup(dir => dir.IsPersistent(AnotherNonPersistentPeer.Id)).Returns(false);
 
-            Transport = new PersistentTransport(configuration.Object, InnerTransport, PeerDirectory.Object, new DefaultMessageSendingStrategy());
+            Transport = new PersistentTransport(configuration, InnerTransport, PeerDirectory.Object, new DefaultMessageSendingStrategy());
             Transport.Configure(Self.Id, "test");
 
             MessagesForwardedToBus = new ConcurrentQueue<TransportMessage>();
@@ -115,4 +118,4 @@ namespace Abc.Zebus.Tests.Persistence
             updatedPeer.UpdateAction.ShouldEqual(updateAction);
         }
     }
-}
+}

+ 2 - 2
src/Abc.Zebus.Tests/Transport/ZmqTransportPerformanceTests.cs

@@ -60,10 +60,10 @@ namespace Abc.Zebus.Tests.Transport
 
         private ZmqTransport CreateAndStartZmqTransport(string peerId, Action<TransportMessage> onMessageReceived = null)
         {
-            var configurationMock = new Mock<IZmqTransportConfiguration>();
+            var configuration = new ZmqTransportConfiguration();
             var zmqSocketOptions = new ZmqSocketOptions { SendTimeout = 5.Seconds() };
 
-            var transport = new ZmqTransport(configurationMock.Object, zmqSocketOptions, new DefaultZmqOutboundSocketErrorHandler());
+            var transport = new ZmqTransport(configuration, zmqSocketOptions, new DefaultZmqOutboundSocketErrorHandler());
             transport.Configure(new PeerId(peerId), "test");
 
             if (onMessageReceived != null)

+ 9 - 9
src/Abc.Zebus.Tests/Transport/ZmqTransportTests.cs

@@ -54,9 +54,8 @@ namespace Abc.Zebus.Tests.Transport
         [Test]
         public void should_not_crash_when_stopping_if_it_was_not_started()
         {
-            var configurationMock = new Mock<IZmqTransportConfiguration>();
-            configurationMock.SetupGet(x => x.WaitForEndOfStreamAckTimeout).Returns(100.Milliseconds());
-            var transport = new ZmqTransport(configurationMock.Object, new ZmqSocketOptions(), new DefaultZmqOutboundSocketErrorHandler());
+            var configuration = new ZmqTransportConfiguration { WaitForEndOfStreamAckTimeout = 100.Milliseconds() };
+            var transport = new ZmqTransport(configuration, new ZmqSocketOptions(), new DefaultZmqOutboundSocketErrorHandler());
 
             Assert.That(transport.Stop, Throws.Nothing);
         }
@@ -634,16 +633,17 @@ namespace Abc.Zebus.Tests.Transport
             Wait.Until(() => transport1.OutboundSocketCount == 0, 10.Seconds());
         }
 
-        private ZmqTransport CreateZmqTransport(string endPoint = null, Action<TransportMessage> onMessageReceived = null, string peerId = null, string environment = _environment, ZmqSocketOptions socketOptions = null)
+        private ZmqTransport CreateZmqTransport(string endPoint = "tcp://*:*", Action<TransportMessage> onMessageReceived = null, string peerId = null, string environment = _environment, ZmqSocketOptions socketOptions = null)
         {
-            var configurationMock = new Mock<IZmqTransportConfiguration>();
-            configurationMock.SetupGet(x => x.InboundEndPoint).Returns(endPoint);
-            configurationMock.SetupGet(x => x.WaitForEndOfStreamAckTimeout).Returns(1.Second());
+            var configuration = new ZmqTransportConfiguration(endPoint)
+            {
+                WaitForEndOfStreamAckTimeout = 1.Second(),
+            };
 
             // Previous code used a specific SendTimeout of 500 ms for unknown reasons.
             var effectiveSocketOptions = socketOptions ?? new ZmqSocketOptions();
 
-            var transport = new ZmqTransport(configurationMock.Object, effectiveSocketOptions, new DefaultZmqOutboundSocketErrorHandler());
+            var transport = new ZmqTransport(configuration, effectiveSocketOptions, new DefaultZmqOutboundSocketErrorHandler());
             transport.SetLogId(_transports.Count);
 
             _transports.Add(transport);
@@ -657,7 +657,7 @@ namespace Abc.Zebus.Tests.Transport
             return transport;
         }
 
-        private ZmqTransport CreateAndStartZmqTransport(string endPoint = null, Action<TransportMessage> onMessageReceived = null, string peerId = null, string environment = _environment, ZmqSocketOptions socketOptions = null)
+        private ZmqTransport CreateAndStartZmqTransport(string endPoint = "tcp://*:*", Action<TransportMessage> onMessageReceived = null, string peerId = null, string environment = _environment, ZmqSocketOptions socketOptions = null)
         {
             return StartZmqTransport(CreateZmqTransport(endPoint, onMessageReceived, peerId, environment, socketOptions));
         }

+ 26 - 0
src/Abc.Zebus/Core/BusConfiguration.cs

@@ -0,0 +1,26 @@
+using System;
+using Abc.Zebus.Util;
+
+namespace Abc.Zebus.Core
+{
+    public class BusConfiguration : IBusConfiguration
+    {
+        public BusConfiguration(string directoryServiceEndPoint)
+            : this(new[] { directoryServiceEndPoint })
+        {
+        }
+
+        public BusConfiguration(string[] directoryServiceEndPoints)
+        {
+            DirectoryServiceEndPoints = directoryServiceEndPoints;
+        }
+
+        public string[] DirectoryServiceEndPoints { get; set; }
+        public TimeSpan RegistrationTimeout { get; set; } = 30.Seconds();
+        public TimeSpan StartReplayTimeout { get; set; } = 30.Seconds();
+        public bool IsPersistent { get; set; } = false;
+        public bool IsDirectoryPickedRandomly { get; set; } = true;
+        public bool IsErrorPublicationEnabled { get; set; } = false;
+        public int MessagesBatchSize { get; set; } = 100;
+    }
+}

+ 9 - 26
src/Abc.Zebus/Core/BusFactory.cs

@@ -39,7 +39,7 @@ namespace Abc.Zebus.Core
         public BusFactory WithConfiguration(string directoryEndPoints, string environment)
         {
             var endpoints = directoryEndPoints.Split(new[] { ' ', ',', ';' }, StringSplitOptions.RemoveEmptyEntries);
-            return WithConfiguration(new BusConfiguration(endpoints), environment);
+            return WithConfiguration(CreateBusConfiguration(endpoints), environment);
         }
 
         public BusFactory WithConfiguration(IBusConfiguration configuration, string environment)
@@ -128,33 +128,16 @@ namespace Abc.Zebus.Core
             return bus;
         }
 
-        private class BusConfiguration : IBusConfiguration
+        private static IBusConfiguration CreateBusConfiguration(string[] directoryServiceEndPoints)
         {
-            public BusConfiguration(params string[] directoryServiceEndPoints)
+            return new BusConfiguration(directoryServiceEndPoints)
             {
-                DirectoryServiceEndPoints = directoryServiceEndPoints;
-                RegistrationTimeout = 10.Second();
-            }
-
-            public string[] DirectoryServiceEndPoints { get; }
-            public TimeSpan RegistrationTimeout { get; }
-            public TimeSpan StartReplayTimeout => 30.Seconds();
-            public bool IsPersistent => false;
-            public bool IsDirectoryPickedRandomly => false;
-            public bool IsErrorPublicationEnabled => false;
-            public int MessagesBatchSize => 200;
-        }
-
-        private class ZmqTransportConfiguration : IZmqTransportConfiguration
-        {
-            public ZmqTransportConfiguration(string inboundEndPoint = "tcp://*:*")
-            {
-                InboundEndPoint = inboundEndPoint;
-                WaitForEndOfStreamAckTimeout = 5.Seconds();
-            }
-
-            public string InboundEndPoint { get; set; }
-            public TimeSpan WaitForEndOfStreamAckTimeout { get; set; }
+                IsPersistent = false,
+                RegistrationTimeout = 10.Seconds(),
+                StartReplayTimeout = 30.Seconds(),
+                IsDirectoryPickedRandomly = false,
+                IsErrorPublicationEnabled = false,
+            };
         }
 
         public BusFactory WithEndpoint(string endpoint)

+ 17 - 0
src/Abc.Zebus/Transport/ZmqTransportConfiguration.cs

@@ -0,0 +1,17 @@
+using System;
+using Abc.Zebus.Util;
+
+namespace Abc.Zebus.Transport
+{
+    public class ZmqTransportConfiguration : IZmqTransportConfiguration
+    {
+        public ZmqTransportConfiguration(string inboundEndPoint = "tcp://*:*")
+        {
+            InboundEndPoint = inboundEndPoint;
+            WaitForEndOfStreamAckTimeout = 5.Seconds();
+        }
+
+        public string InboundEndPoint { get; set; }
+        public TimeSpan WaitForEndOfStreamAckTimeout { get; set; }
+    }
+}