Пример #1
0
        public void Connect(string clusterDns, int maxAttempts = 10, int port = 30777)
        {
            Ensure.NotNullOrEmpty(clusterDns, "clusterDns");
            Ensure.Positive(maxAttempts, "maxAttempts");
            Ensure.Nonnegative(port, "port");

            var task = ConnectAsync(clusterDns, maxAttempts, port);

            task.Wait();
        }
Пример #2
0
        public Task <EventStreamSlice> ReadEventStreamForwardAsync(string stream, int start, int count)
        {
            Ensure.NotNullOrEmpty(stream, "stream");
            Ensure.Nonnegative(start, "start");
            Ensure.Positive(count, "count");
            EnsureActive();

            var source    = new TaskCompletionSource <EventStreamSlice>();
            var operation = new ReadStreamEventsForwardOperation(source, Guid.NewGuid(), stream, start, count, true);

            EnqueueOperation(operation);
            return(source.Task);
        }
Пример #3
0
        public EventStreamSlice ReadEventStreamForward(string stream, int start, int count)
        {
            Ensure.NotNullOrEmpty(stream, "stream");
            Ensure.Nonnegative(start, "start");
            Ensure.Positive(count, "count");
            EnsureActive();

            var task = ReadEventStreamForwardAsync(stream, start, count);

            task.Wait();

            return(task.Result);
        }
Пример #4
0
        public static EventStoreConnection Create(bool allowForwarding        = true,
                                                  int maxConcurrentRequests   = 5000,
                                                  int maxAttemptsForOperation = 10,
                                                  int maxReconnections        = 10,
                                                  ILogger logger = null)
        {
            Ensure.Positive(maxConcurrentRequests, "maxConcurrentRequests");
            Ensure.Positive(maxAttemptsForOperation, "maxAttemptsForOperation");
            Ensure.Nonnegative(maxReconnections, "maxReconnections");

            return(new EventStoreConnection(allowForwarding,
                                            maxConcurrentRequests,
                                            maxAttemptsForOperation,
                                            maxReconnections,
                                            logger));
        }
Пример #5
0
        public Task ConnectAsync(string clusterDns, int maxAttempts = 10, int port = 30777)
        {
            Ensure.NotNullOrEmpty(clusterDns, "clusterDns");
            Ensure.Positive(maxAttempts, "maxAttempts");
            Ensure.Nonnegative(port, "port");

            var explorer = new ClusterExplorer(_allowForwarding, maxAttempts, port);

            return(explorer.Resolve(clusterDns)
                   .ContinueWith(t =>
            {
                var pair = t.Result;
                if (!pair.HasValue)
                {
                    throw new CannotEstablishConnectionException("Failed to find node to connect");
                }

                return EstablishConnectionAsync(pair.Value.TcpEndPoint, pair.Value.HttpEndPoint);
            }));
        }