예제 #1
0
        private Tuple <ICommandOperation, ISubscriptionOperation, RESPObject[]> Pack <T>(ExecutionPlan plan, T parameters)
            where T : class
        {
            var respCommand          = plan.Bind(parameters);
            var responsesPlaceholder = new RESPObject[respCommand.Length];

            ICommandOperation      commandOperation = null;
            ISubscriptionOperation subOp            = null;

            var hasSubscriptions = false;
            var hasCommands      = false;

            IdentifyOperationMainRoute(respCommand, ref hasCommands, ref hasSubscriptions);

            if (!hasCommands && !hasSubscriptions)
            {
                throw new RedisClientParsingException("The given RESP commands do not contain Redis commands.");
            }

            if (hasCommands)
            {
                commandOperation = new CommandOperation(respCommand, responsesPlaceholder, _procedures);
            }

            if (hasSubscriptions)
            {
                if (_subscriber == null)
                {
                    _subscriber = _subscribers.Provide();
                }
                subOp = new SubscriptionOperation(this, respCommand, responsesPlaceholder, _subscriber.Subscriptions);
            }

            return(new Tuple <ICommandOperation, ISubscriptionOperation, RESPObject[]>(commandOperation, subOp, responsesPlaceholder));
        }
        public SubscriptionItem(ISubscriptionOperation operation, int maxRetries, TimeSpan timeout)
        {
            Ensure.NotNull(operation, "operation");

            Operation   = operation;
            MaxRetries  = maxRetries;
            Timeout     = timeout;
            CreatedTime = DateTime.UtcNow;

            CorrelationId = Guid.NewGuid();
            RetryCount    = 0;
            LastUpdated   = DateTime.UtcNow;
        }
예제 #3
0
        public SubscriptionItem(ISubscriptionOperation operation, int maxRetries, TimeSpan timeout)
        {
            Ensure.NotNull(operation, "operation");

            Operation = operation;
            MaxRetries = maxRetries;
            Timeout = timeout;
            CreatedTime = DateTime.UtcNow;

            CorrelationId = Guid.NewGuid();
            RetryCount = 0;
            LastUpdated = DateTime.UtcNow;
        }
예제 #4
0
        internal ExecutionToken(ICommandOperation commandOperation, ISubscriptionOperation subscriptionOperation)
        {
            Contract.Assert(commandOperation != null || subscriptionOperation != null, "In ExecutionToken both operations cannot be null.");

            CommandOperation      = commandOperation;
            SubscriptionOperation = subscriptionOperation;

            if (commandOperation != null)
            {
                _signalingsNeeded++;
            }

            if (subscriptionOperation != null)
            {
                _signalingsNeeded++;
            }
        }
예제 #5
0
 internal SyncExecutionToken(ICommandOperation commandOperation, ISubscriptionOperation subscriptionOperation)
     : base(commandOperation, subscriptionOperation)
 {
     _reset = new ManualResetEventSlim(false);
 }
예제 #6
0
 internal AsyncExecutionToken(ICommandOperation commandOperation, ISubscriptionOperation subscriptionOperation)
     : base(commandOperation, subscriptionOperation)
 {
     _completion = new TaskCompletionSource <Object>();
 }
예제 #7
0
 internal NoWaitExecutionToken(ICommandOperation commandOperation, ISubscriptionOperation subscriptionOperation)
     : base(commandOperation, subscriptionOperation)
 {
 }