Esempio n. 1
0
 public ConnectionState Register(EventsTransport transport)
 {
     timeSensitiveStore.Seen(transport.Id);
     transport.Disconnected += () => TimeSensitiveStore.Missing(transport.Id);
     return(connections.AddOrUpdate(transport.Id, new ConnectionState(transport), (s, state) =>
     {
         state.Reconnect(transport);
         return state;
     }));
 }
Esempio n. 2
0
		public ConnectionState Register(EventsTransport transport)
		{
			timeSensitiveStore.Seen(transport.Id);
			transport.Disconnected += () => TimeSensitiveStore.Missing(transport.Id);
			return connections.AddOrUpdate(transport.Id, new ConnectionState(transport), (s, state) =>
			                                                                             	{
			                                                                             		state.Reconnect(transport);
			                                                                             		return state;
			                                                                             	});
		}
Esempio n. 3
0
        public void Reconnect(EventsTransport transport)
        {
            eventsTransport = transport;
            var    items = new List <object>();
            object result;

            while (pendingMessages.TryDequeue(out result))
            {
                items.Add(result);
            }

            eventsTransport.SendManyAsync(items)
            .ContinueWith(task =>
            {
                if (task.IsFaulted == false)
                {
                    return;
                }
                foreach (var item in items)
                {
                    pendingMessages.Enqueue(item);
                }
            });
        }
Esempio n. 4
0
		public Task HandleChangesRequest(IHttpContext context, Action onDisconnect)
		{
			var sw = Stopwatch.StartNew();
			try
			{
				if (SetupRequestToProperDatabase(context) == false)
				{
					FinalizeRequestSafe(context);
					onDisconnect();
					return new CompletedTask();
				}

				if (!SetThreadLocalState(context))
				{
					FinalizeRequestSafe(context);
					onDisconnect();
					return new CompletedTask();
				}
				var eventsTransport = new EventsTransport(context);
				eventsTransport.Disconnected += onDisconnect;
				var handleChangesRequest = eventsTransport.ProcessAsync();
				CurrentDatabase.TransportState.Register(eventsTransport);
				return handleChangesRequest;
			}
			catch (Exception e)
			{
				try
				{
					ExceptionHandler.TryHandleException(context, e);
					LogException(e);
				}
				finally
				{
					FinalizeRequestSafe(context);
				}
				onDisconnect();
				return new CompletedTask();
			}
			finally
			{
				try
				{
					LogHttpRequestStats(new LogHttpRequestStatsParams(
											sw,
											context.Request.Headers,
											context.Request.HttpMethod,
											context.Response.StatusCode,
											context.Request.Url.PathAndQuery));
				}
				catch (Exception e)
				{
					logger.WarnException("Could not gather information to log request stats", e);
				}
				ResetThreadLocalState();
			}
		}
Esempio n. 5
0
		public ConnectionState(EventsTransport eventsTransport)
		{
			this.eventsTransport = eventsTransport;
		}
Esempio n. 6
0
		public void Reconnect(EventsTransport transport)
		{
			eventsTransport = transport;
			var items = new List<object>();
			object result;
			while (pendingMessages.TryDequeue(out result))
			{
				items.Add(result);
			}

			eventsTransport.SendManyAsync(items)
				.ContinueWith(task =>
								{
									if (task.IsFaulted == false)
										return;
									foreach (var item in items)
									{
										pendingMessages.Enqueue(item);
									}
								});
		}
Esempio n. 7
0
 public void Reconnect(EventsTransport transport)
 {
     eventsTransport = transport;
 }
Esempio n. 8
0
 public ConnectionState(EventsTransport eventsTransport)
 {
     this.eventsTransport = eventsTransport;
 }
Esempio n. 9
0
 public void Reconnect(EventsTransport transport)
 {
     eventsTransport = transport;
 }