Skip to content

Commit

Permalink
make settings visible on connection.
Browse files Browse the repository at this point in the history
  • Loading branch information
gregoryyoung committed Oct 23, 2014
1 parent d37f548 commit 30e0fbf
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 4 deletions.
Expand Up @@ -10,7 +10,6 @@
using EventStore.ClientAPI.SystemData;
using EventStore.Core.Bus;
using EventStore.Core.Messages;
using EventStore.Core.Messaging;
using EventStore.Core.Services.UserManagement;

namespace EventStore.ClientAPI.Embedded
Expand Down Expand Up @@ -94,6 +93,10 @@ public EventStoreEmbeddedNodeConnection(ConnectionSettings settings, string conn
bus.Subscribe(new AdHocHandler<SystemMessage.BecomeShutdown>(_ => Disconnected(this, new ClientConnectionEventArgs(this, new IPEndPoint(IPAddress.None, 0)))));
}

public ConnectionSettings Settings { get { return _settings; } }

public ClusterSettings ClusterSettings { get { return null; } }

public string ConnectionName { get { return _connectionName; } }

public Task ConnectAsync()
Expand Down
4 changes: 2 additions & 2 deletions src/EventStore.ClientAPI/EventStoreConnection.cs
Expand Up @@ -31,7 +31,7 @@ public static IEventStoreConnection Create(ConnectionSettings settings, IPEndPoi
{
Ensure.NotNull(settings, "settings");
Ensure.NotNull(tcpEndPoint, "tcpEndPoint");
return new EventStoreNodeConnection(settings, new StaticEndPointDiscoverer(tcpEndPoint, settings.UseSslConnection), connectionName);
return new EventStoreNodeConnection(settings, null, new StaticEndPointDiscoverer(tcpEndPoint, settings.UseSslConnection), connectionName);
}

/// <summary>
Expand All @@ -54,7 +54,7 @@ public static IEventStoreConnection Create(ConnectionSettings connectionSettings
clusterSettings.GossipSeeds,
clusterSettings.GossipTimeout);

return new EventStoreNodeConnection(connectionSettings, endPointDiscoverer, connectionName);
return new EventStoreNodeConnection(connectionSettings, clusterSettings, endPointDiscoverer, connectionName);
}
}
}
21 changes: 20 additions & 1 deletion src/EventStore.ClientAPI/EventStoreNodeConnection.cs
Expand Up @@ -31,22 +31,41 @@ internal class EventStoreNodeConnection : IEventStoreConnection, IEventStoreTran

private readonly string _connectionName;
private readonly ConnectionSettings _settings;
private readonly ClusterSettings _clusterSettings;
private readonly IEndPointDiscoverer _endPointDiscoverer;
private readonly EventStoreConnectionLogicHandler _handler;

/// <summary>
/// Returns the <see cref="ConnectionSettings"/> use to create this connection
/// </summary>
public ConnectionSettings Settings
{
get { return _settings; }
}

/// <summary>
/// Returns the <see cref="ClusterSettings"/> use to create this connection
/// </summary>
public ClusterSettings ClusterSettings
{
get { return _clusterSettings; }
}

/// <summary>
/// Constructs a new instance of a <see cref="EventStoreConnection"/>
/// </summary>
/// <param name="settings">The <see cref="ConnectionSettings"/> containing the settings for this connection.</param>
/// <param name="clusterSettings"></param>
/// <param name="endPointDiscoverer">Discoverer of destination node end point.</param>
/// <param name="connectionName">Optional name of connection (will be generated automatically, if not provided)</param>
internal EventStoreNodeConnection(ConnectionSettings settings, IEndPointDiscoverer endPointDiscoverer, string connectionName)
internal EventStoreNodeConnection(ConnectionSettings settings, ClusterSettings clusterSettings, IEndPointDiscoverer endPointDiscoverer, string connectionName)
{
Ensure.NotNull(settings, "settings");
Ensure.NotNull(endPointDiscoverer, "endPointDiscoverer");

_connectionName = connectionName ?? string.Format("ES-{0}", Guid.NewGuid());
_settings = settings;
_clusterSettings = clusterSettings;
_endPointDiscoverer = endPointDiscoverer;
_handler = new EventStoreConnectionLogicHandler(this, settings);
}
Expand Down
11 changes: 11 additions & 0 deletions src/EventStore.ClientAPI/IEventStoreConnection.cs
Expand Up @@ -22,6 +22,17 @@ namespace EventStore.ClientAPI
/// </remarks>
public interface IEventStoreConnection : IDisposable
{

/// <summary>
/// Returns the <see cref="ConnectionSettings"/> use to create this connection
/// </summary>
ConnectionSettings Settings { get; }

/// <summary>
/// Returns the <see cref="ClusterSettings"/> use to create this connection
/// </summary>
ClusterSettings ClusterSettings { get; }

/// <summary>
/// Gets the name of this connection. A connection name can be used for disambiguation
/// in log files.
Expand Down

0 comments on commit 30e0fbf

Please sign in to comment.