コード例 #1
0
        public void IsAllowed_20ExecutionsOnFreeApp_AllowsAll()
        {
            var limiter = new Limiter("free");

            for (int i = 0; i < 20; i++)
            {
                Assert.IsTrue(limiter.IsAllowed(GetCurrentMethod().Name), $"Iteration index {i} was improperly disallowed");
            }
        }
コード例 #2
0
        private async Task <MessageProcessInstruction> GetMessageProcessInstruction(string routingKeyOrQueueName, string consumerTag,
                                                                                    long firstErrorTimestamp, string exchange, string message, string messageAdditionalInfo)
        {
            var isAllowed = true;

            if (Limiter != null)
            {
                isAllowed = Limiter.IsAllowed(routingKeyOrQueueName, consumerTag, firstErrorTimestamp, exchange, message);
            }

            if (!isAllowed)
            {
                return(new MessageProcessInstruction(Limiter.DeniedProcessInstruction, messageAdditionalInfo));
            }

            var messageProcessInstruction =
                await OnReceiveMessage(routingKeyOrQueueName, consumerTag, firstErrorTimestamp, exchange, message, messageAdditionalInfo)
                .ConfigureAwait(false);

            return(messageProcessInstruction);
        }