Create() public static method

Creates a new IEventStoreConnection to EventStore cluster using specific ConnectionSettings and ClusterSettings
public static Create ( EventStore.ClientAPI.ConnectionSettings connectionSettings, EventStore.ClientAPI.ClusterSettings clusterSettings, string connectionName = null ) : IEventStoreConnection
connectionSettings EventStore.ClientAPI.ConnectionSettings The to apply to the new connection
clusterSettings EventStore.ClientAPI.ClusterSettings The that determine cluster behavior.
connectionName string Optional name of connection (will be generated automatically, if not provided)
return IEventStoreConnection
        public IEventStoreConnection CreateConnection(
            Func <ConnectionSettingsBuilder, ConnectionSettingsBuilder> configureSettings = default,
            int?port = default, bool useDnsEndPoint = true)
        {
            var settings = (configureSettings ?? DefaultConfigureSettings)(DefaultBuilder).Build();

            return(EventStoreConnection.Create(
                       settings,
                       useDnsEndPoint
                                        ? new DnsEndPoint("localhost", port ?? 1113)
                                        : new IPEndPoint(IPAddress.Loopback, port ?? 1113)));
        }
        public IEventStoreConnection CreateConnectionWithConnectionString(string configureSettings = default,
                                                                          int?port = default, bool useDnsEndPoint = false)
        {
            var settings = configureSettings ?? DefaultConfigureSettingsForConnectionString;
            var host     = useDnsEndPoint ? "localhost" : IPAddress.Loopback.ToString();

            port ??= 1113;

            settings += "UseSslConnection=true;ValidateServer=false;";

            return(EventStoreConnection.Create($"ConnectTo=tcp://{host}:{port};{settings}"));
        }
Beispiel #3
0
        public IEventStoreConnection CreateConnectionWithConnectionString(
            bool useSsl,
            string configureSettings = default,
            int port            = 2113,
            bool useDnsEndPoint = false)
        {
            var settings = configureSettings ?? DefaultConfigureSettingsForConnectionString;
            var host     = useDnsEndPoint ? "localhost" : IPAddress.Loopback.ToString();

            if (useSsl)
            {
                settings += "UseSslConnection=true;ValidateServer=false;";
            }
            else
            {
                settings += "UseSslConnection=false;";
            }

            var gossipSeeds       = GetGossipSeedEndPointsExceptFor(-1, port, useDnsEndPoint);
            var gossipSeedsString = "";

            for (var i = 0; i < gossipSeeds.Length; i++)
            {
                if (i > 0)
                {
                    gossipSeedsString += ",";
                }
                gossipSeedsString += host + ":" + gossipSeeds[i].GetPort();
            }

            settings += "CustomHttpMessageHandler=SkipCertificateValidation;";

            var connectionString = $"GossipSeeds={gossipSeedsString};{settings}";

            return(EventStoreConnection.Create(connectionString));
        }
Beispiel #4
0
        public IEventStoreConnection CreateConnectionWithGossipSeeds(
            Func <ConnectionSettingsBuilder, ConnectionSettingsBuilder> configureSettings = default,
            int port                = 2113,
            bool useDnsEndPoint     = false,
            int maxDiscoverAttempts = 1)
        {
            var settings = (configureSettings ?? DefaultConfigureSettings)(DefaultBuilder)
                           .Build();
            var gossipSeeds     = GetGossipSeedEndPointsExceptFor(-1, port, useDnsEndPoint);
            var clusterSettings = new ClusterSettingsBuilder()
                                  .DiscoverClusterViaGossipSeeds()
                                  .SetGossipSeedEndPoints(true, gossipSeeds);

            if (maxDiscoverAttempts == -1)
            {
                clusterSettings = clusterSettings.KeepDiscovering();
            }
            else
            {
                clusterSettings = clusterSettings.SetMaxDiscoverAttempts(maxDiscoverAttempts);
            }

            return(EventStoreConnection.Create(settings, clusterSettings.Build()));
        }