<commit_before>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Kayak;
using Kayak.Http;
using System.Diagnostics;
using System.Net;

namespace Gate.Kayak
{
    public static class KayakGate
    {
        public static void Start(ISchedulerDelegate schedulerDelegate, IPEndPoint listenEP)
        {
            Start(schedulerDelegate, listenEP, AppBuilder.BuildConfiguration());
        }

        public static void Start(ISchedulerDelegate schedulerDelegate, IPEndPoint listenEP, AppDelegate app)
        {
            Start(schedulerDelegate, listenEP, app, null);
        }

        public static void Start(ISchedulerDelegate schedulerDelegate, IPEndPoint listenEP, AppDelegate app, IDictionary<string, object> context)
        {
            var scheduler = KayakScheduler.Factory.Create(schedulerDelegate);
            var server = KayakServer.Factory.CreateGate(app, scheduler, context);
            scheduler.Post(() => server.Listen(listenEP));
            scheduler.Start();
        }
    }

    public static class HttpServerExtensions
    {
        public static IServer CreateGate(this IServerFactory factory, AppDelegate app, IScheduler scheduler)<commit_msg>a few handy extensions, and properly stop server from listening<commit_after>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Kayak;
using Kayak.Http;
using System.Diagnostics;
using System.Net;

namespace Gate.Kayak
{
    public static class KayakGate
    {
        public static void Start(ISchedulerDelegate schedulerDelegate, IPEndPoint listenEP)
        {
            Start(schedulerDelegate, listenEP, AppBuilder.BuildConfiguration());
        }
		
        public static void Start(ISchedulerDelegate schedulerDelegate, IPEndPoint listenEP, string configurationString)
		{
			Start(schedulerDelegate, listenEP, AppBuilder.BuildConfiguration(configurationString));
		}
		
        public static void Start(ISchedulerDelegate schedulerDelegate, IPEndPoint listenEP, Action<IAppBuilder> configuration)
		{
			Start(schedulerDelegate, listenEP, AppBuilder.BuildConfiguration(configuration));
		}

        public static void Start(ISchedulerDelegate schedulerDelegate, IPEndPoint listenEP, AppDelegate app)
        {
            Start(schedulerDelegate, listenEP, app, null);
        }

        public static void Start(ISchedulerDelegate schedulerDelegate, IPEndPoint listenEP, AppDelegate app, IDictionary<string, object> context)
        {
            var scheduler = KayakScheduler.Factory.Create(schedulerDelegate);
            var server = KayakServer.Factory.CreateGate(app, scheduler, context);
            
			using (server.Listen(listenEP))
            	scheduler.Start();
        }
    }

    public static class HttpServerExtensions
    {
        public static IServer CreateGate(this IServerFactory factory, AppDelegate app, IScheduler scheduler)
{'fraction_non_alphanumeric': 0.07155083875385142, 'fraction_numerical': 0.0, 'mean_word_length': 3.488479262672811, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 7, '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': '3390903', 'n_tokens_mistral': 751, 'n_tokens_neox': 741, 'n_words': 196}