private void ExecuteOperation(OperationItem operation, WebSocketConnection connection) { operation.ConnectionId = connection.ConnectionId; operation.LastUpdated = DateTime.UtcNow; _activeOperations.Add(operation.Ref, operation); var package = operation.Operation.CreateNetworkPackage(operation.Ref); LogDebug("ExecuteOperation push {0}, {1}, {2}.", package.ChannelEvent, package.PushRef, operation); connection.EnqueueSend(package.ToMessage()); }
public bool RemoveOperation(OperationItem operation) { if (!_activeOperations.Remove(operation.Ref)) { LogDebug("RemoveOperation FAILED for {0}", operation); return(false); } LogDebug("RemoveOperation SUCCEEDED for {0}", operation); _totalOperationCount = _activeOperations.Count + _waitingOperations.Count; return(true); }
bool TryExpireItem(DateTime cutoffDate, OperationItem operation) { if (operation.CreatedTime > cutoffDate) { return(false); } var err = $"WebSocketConnection: request expired.\n" + $"UTC now: {DateTime.UtcNow:HH:mm:ss.fff}, operation: {operation}."; _settings.Logger.Debug(err); operation.Operation.Fail(new OperationExpiredException(err)); return(true); }
public void ScheduleOperationRetry(OperationItem operation) { if (!RemoveOperation(operation)) { return; } LogDebug("ScheduleOperationRetry for {0}", operation); if (operation.MaxRetries >= 0 && operation.RetryCount >= operation.MaxRetries) { operation.Operation.Fail(new RetriesLimitReachedException(operation.ToString(), operation.RetryCount)); return; } _retryPendingOperations.Add(operation); }
public bool TryGetActiveOperation(long correlationId, out OperationItem operation) { return(_activeOperations.TryGetValue(correlationId, out operation)); }
public void ScheduleOperation(OperationItem operation, WebSocketConnection connection) { Ensure.NotNull(connection, "connection"); _waitingOperations.Enqueue(operation); TryScheduleWaitingOperations(connection); }
public void EnqueueOperation(OperationItem operation) { LogDebug("EnqueueOperation WAITING for {0}.", operation); _waitingOperations.Enqueue(operation); }