Created
July 26, 2018 23:47
-
-
Save bboyle1234/97f65482db7144d22a2f410e516b78fc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: '2' | |
services: | |
eventstore1: | |
image: eventstore/eventstore | |
ports: | |
- 12113:2113/tcp | |
- 11113:1113/tcp | |
environment: | |
EVENTSTORE_CLUSTER_DNS: eventstore1 | |
EVENTSTORE_CLUSTER_GOSSIP_PORT: '2112' | |
EVENTSTORE_CLUSTER_SIZE: '3' | |
EVENTSTORE_EXT_HTTP_PORT_ADVERTISE_AS: '12113' | |
EVENTSTORE_EXT_TCP_PORT_ADVERTISE_AS: '11113' | |
EVENTSTORE_EXT_IP: '127.0.0.1' | |
EVENTSTORE_EXT_IP_ADVERTISE_AS: '127.0.0.1' | |
EVENTSTORE_RUN_PROJECTIONS: 'All' | |
EVENTSTORE_START_STANDARD_PROJECTIONS: 'True' | |
entrypoint: | |
- /bin/bash | |
command: | |
- -c | |
- 'sed -i "/IntIpAdvertiseAs\:/d" /etc/eventstore/eventstore.conf && echo "IntIpAdvertiseAs: $$(hostname -i)" >> /etc/eventstore/eventstore.conf && sed -i "/IntIp\:/d" /etc/eventstore/eventstore.conf && echo "IntIp: $$(hostname -i)" >> /etc/eventstore/eventstore.conf && /entrypoint.sh' | |
eventstore2: | |
image: eventstore/eventstore | |
ports: | |
- 22113:2113/tcp | |
- 21113:1113/tcp | |
environment: | |
EVENTSTORE_CLUSTER_DNS: eventstore1 | |
EVENTSTORE_CLUSTER_GOSSIP_PORT: '2112' | |
EVENTSTORE_CLUSTER_SIZE: '3' | |
EVENTSTORE_EXT_HTTP_PORT_ADVERTISE_AS: '22113' | |
EVENTSTORE_EXT_TCP_PORT_ADVERTISE_AS: '21113' | |
EVENTSTORE_EXT_IP: '127.0.0.1' | |
EVENTSTORE_EXT_IP_ADVERTISE_AS: '127.0.0.1' | |
EVENTSTORE_RUN_PROJECTIONS: 'All' | |
EVENTSTORE_START_STANDARD_PROJECTIONS: 'True' | |
entrypoint: | |
- /bin/bash | |
command: | |
- -c | |
- 'sed -i "/IntIpAdvertiseAs\:/d" /etc/eventstore/eventstore.conf && echo "IntIpAdvertiseAs: $$(hostname -i)" >> /etc/eventstore/eventstore.conf && sed -i "/IntIp\:/d" /etc/eventstore/eventstore.conf && echo "IntIp: $$(hostname -i)" >> /etc/eventstore/eventstore.conf && /entrypoint.sh' | |
eventstore3: | |
image: eventstore/eventstore | |
ports: | |
- 32113:2113/tcp | |
- 31113:1113/tcp | |
environment: | |
EVENTSTORE_CLUSTER_DNS: eventstore1 | |
EVENTSTORE_CLUSTER_GOSSIP_PORT: '2112' | |
EVENTSTORE_CLUSTER_SIZE: '3' | |
EVENTSTORE_EXT_HTTP_PORT_ADVERTISE_AS: '32113' | |
EVENTSTORE_EXT_TCP_PORT_ADVERTISE_AS: '31113' | |
EVENTSTORE_EXT_IP: '127.0.0.1' | |
EVENTSTORE_EXT_IP_ADVERTISE_AS: '127.0.0.1' | |
EVENTSTORE_RUN_PROJECTIONS: 'All' | |
EVENTSTORE_START_STANDARD_PROJECTIONS: 'True' | |
entrypoint: | |
- /bin/bash | |
command: | |
- -c | |
- 'sed -i "/IntIpAdvertiseAs\:/d" /etc/eventstore/eventstore.conf && echo "IntIpAdvertiseAs: $$(hostname -i)" >> /etc/eventstore/eventstore.conf && sed -i "/IntIp\:/d" /etc/eventstore/eventstore.conf && echo "IntIp: $$(hostname -i)" >> /etc/eventstore/eventstore.conf && /entrypoint.sh' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Microsoft.Extensions.DependencyInjection; | |
using Microsoft.Extensions.Logging; | |
using Microsoft.VisualStudio.TestTools.UnitTesting; | |
using System; | |
using System.Net; | |
using System.Threading.Tasks; | |
using ESClusterSettings = EventStore.ClientAPI.ClusterSettings; | |
using ESConnection = EventStore.ClientAPI.EventStoreConnection; | |
using ESConnectionSettings = EventStore.ClientAPI.ConnectionSettings; | |
using ESUserCredentials = EventStore.ClientAPI.SystemData.UserCredentials; | |
namespace Apex.Events.EventStore.Test { | |
[TestClass] | |
public class EventStoreConnections { | |
[TestMethod] | |
public async Task ConnectToCluster() { | |
var tcs = new TaskCompletionSource<object>(); | |
var settings = ESConnectionSettings.Create() | |
.EnableVerboseLogging() | |
.SetDefaultUserCredentials(new ESUserCredentials("admin", "changeit")) | |
.Build(); | |
var clusterSettings = ESClusterSettings.Create() | |
.DiscoverClusterViaGossipSeeds() | |
.SetGossipSeedEndPoints(new[]{ | |
new IPEndPoint(IPAddress.Loopback, 12113), | |
}) | |
.Build(); | |
var connection = ESConnection.Create(settings, clusterSettings, "test connection"); | |
connection.Closed += (_, e) => { | |
// Happens after ten reconnection attempts. | |
tcs.SetException(new Exception("Closed")); | |
}; | |
connection.Connected += (_, e) => { | |
// Does not happen | |
tcs.SetResult(null); | |
}; | |
connection.Disconnected += (_, e) => { | |
// Does not happen | |
tcs.SetException(new Exception("Disconnected")); | |
}; | |
connection.ErrorOccurred += (_, e) => { | |
// Does not happen | |
tcs.SetException(e.Exception); | |
}; | |
connection.Reconnecting += (_, e) => { | |
// Happens 10 times | |
}; | |
// This succeeds | |
await connection.ConnectAsync(); | |
// This fails | |
await tcs.Task; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment