<commit_before>﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using InEngine.Core.Exceptions;
using Newtonsoft.Json;

namespace InEngine.Core.Queuing.Clients
{
    public class InMemoryClient : IQueueClient
    {
        public string QueueBaseName { get; set; } = "InEngineQueue";
        public string QueueName { get; set; } = "Primary";
        public string PendingQueueName { get { return QueueBaseName + $":{QueueName}:Pending"; } }
        public string InProgressQueueName { get { return QueueBaseName + $":{QueueName}:InProgress"; } }
        public string FailedQueueName { get { return QueueBaseName + $":{QueueName}:Failed"; } }
        public bool UseCompression { get; set; }

        public IDictionary<string,Queue<IMessage>> PendingQueue { get; set; }
        public IDictionary<string,List<IMessage>> InProgressMessages { get; set; }
        public IDictionary<string,List<IMessage>> FailedMessages { get; set; }

        public void Publish(ICommand command)
        {
            var serializedCommand = JsonConvert.SerializeObject(command);
            PendingQueue[QueueName].Enqueue(new Message {
                IsCompressed = UseCompression,
                CommandClassName = command.GetType().FullName,
                CommandAssemblyName = command.GetType().Assembly.GetName().Name + ".dll",
                SerializedCommand = UseCompression ? serializedCommand.Compress() : serializedCommand
            });
        }

        public bool Consume()
        {
            var message = PendingQueue[QueueName].Dequeue();
            if (message == null)
                return false;
            InProgressMessages.Add(message);
            var commandInstance = Queue.ExtractCommandInstanceFromMessage(message);
            try
            {
                commandInstance.Run();<commit_msg>Fix queue references in InMemory queue<commit_after>﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using InEngine.Core.Exceptions;
using Newtonsoft.Json;

namespace InEngine.Core.Queuing.Clients
{
    public class InMemoryClient : IQueueClient
    {
        public string QueueBaseName { get; set; } = "InEngineQueue";
        public string QueueName { get; set; } = "Primary";
        public string PendingQueueName { get { return QueueBaseName + $":{QueueName}:Pending"; } }
        public string InProgressQueueName { get { return QueueBaseName + $":{QueueName}:InProgress"; } }
        public string FailedQueueName { get { return QueueBaseName + $":{QueueName}:Failed"; } }
        public bool UseCompression { get; set; }

        public IDictionary<string,Queue<IMessage>> PendingQueue { get; set; }
        public IDictionary<string,List<IMessage>> InProgressMessages { get; set; }
        public IDictionary<string,List<IMessage>> FailedMessages { get; set; }

        public void Publish(ICommand command)
        {
            var serializedCommand = JsonConvert.SerializeObject(command);
            PendingQueue[QueueName].Enqueue(new Message {
                IsCompressed = UseCompression,
                CommandClassName = command.GetType().FullName,
                CommandAssemblyName = command.GetType().Assembly.GetName().Name + ".dll",
                SerializedCommand = UseCompression ? serializedCommand.Compress() : serializedCommand
            });
        }

        public bool Consume()
        {
            var message = PendingQueue[QueueName].Dequeue();
            if (message == null)
                return false;
            InProgressMessages[QueueName].Add(message);
            var commandInstance = Queue.ExtractCommandInstanceFromMessage(message);
            try
            {
                commandInstance.Run();
{'fraction_non_alphanumeric': 0.09745762711864407, 'fraction_numerical': 0.0, 'mean_word_length': 2.6956947162426617, 'pattern_counts': {'":': 6, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5995161', 'n_tokens_mistral': 964, 'n_tokens_neox': 941, 'n_words': 220}