<commit_before>﻿// -----------------------------------------------------------------------
//  <copyright file="HedProxyHandler.cs" company="Hibernating Rhinos LTD">
//      Copyright (c) Hibernating Rhinos LTD. All rights reserved.
//  </copyright>
// -----------------------------------------------------------------------

using System;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using Newtonsoft.Json;
using Switchboard.Server;

namespace Switchboard.ConsoleHost
{
	public class HedProxyHandler : ISwitchboardRequestHandler
	{
		private readonly string config = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "topology.json");
		private Regex _pathMatch = new Regex(@"^/(\d+)(/.+)");

		private readonly ProxyTopology _topology = new ProxyTopology
		{
			Paths =
			{
				{"1", new ProxyPath
				{
					From = "http://localhost:8080/databases/abc",
					To = new Uri("http://localhost:8080/databases/def"),
					Behavior = ProxyBehavior.Slow
				}}
			}
		};

		public HedProxyHandler()
		{
			if (File.Exists(config))
			{
				_topology = JsonConvert.DeserializeObject<ProxyTopology>(File.ReadAllText(config));
			}
		}

		private ThreadLocal<Random> _random = new ThreadLocal<Random>(() => new Random());

		public async Task<SwitchboardResponse> GetResponseAsync(SwitchboardContext context, SwitchboardRequest request)
		{<commit_msg>Minor<commit_after>﻿// -----------------------------------------------------------------------
//  <copyright file="HedProxyHandler.cs" company="Hibernating Rhinos LTD">
//      Copyright (c) <NAME> LTD. All rights reserved.
//  </copyright>
// -----------------------------------------------------------------------

using System;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using Newtonsoft.Json;
using Switchboard.Server;

namespace Switchboard.ConsoleHost
{
	public class HedProxyHandler : ISwitchboardRequestHandler
	{
		private readonly string config = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "topology.json");
		private readonly ThreadLocal<Random> _random = new ThreadLocal<Random>(() => new Random());
		private readonly Regex _pathMatch = new Regex(@"^/(\d+)(/.+)");

		private readonly ProxyTopology _topology = new ProxyTopology
		{
			Paths =
			{
				{"1", new ProxyPath
				{
					From = "http://localhost:8080/databases/abc",
					To = new Uri("http://localhost:8080/databases/def"),
					Behavior = ProxyBehavior.Slow
				}}
			}
		};

		public HedProxyHandler()
		{
			if (File.Exists(config))
			{
				_topology = JsonConvert.DeserializeObject<ProxyTopology>(File.ReadAllText(config));
			}
		}


		public async Task<SwitchboardResponse> GetResponseAsync(SwitchboardContext context, SwitchboardRequest request)
		{
{'fraction_non_alphanumeric': 0.20473996050032917, 'fraction_numerical': 0.005924950625411455, 'mean_word_length': 2.79875, 'pattern_counts': {'":': 0, '<': 16, '<?xml version=': 0, '>': 18, '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': '5824913', 'n_tokens_mistral': 961, 'n_tokens_neox': 841, 'n_words': 187}