<commit_before>package main

import (
    "fmt"
    "net/http"
    "encoding/json"
    "time"
    "image/png"
    "log"
    "functorama.com/demo/libgodelbrot"
    "bytes"
    "runtime"
)

type WebCommand string
const (
    render = WebCommand("render")
    displayImage = WebCommand("displayImage")
)

type WebRenderParameters struct {
    ImageWidth uint
    ImageHeight uint
    RealMin float64
    RealMax float64
    ImagMin float64
    ImagMax float64
}

type RenderMetadata struct {
    Renderer string
    Palette string
    RenderDuration string
}

type GodelbrotPacket struct {
    Command WebCommand
    Render WebRenderParameters
    Metadata RenderMetadata
}

const godelbrotHeader string = "X-Godelbrot-Packet"
const godelbrotGetParam string = "godelbrotPacket"

type queueCommand uint

const (
    queueRender = queueCommand(iota)
    queueStop = queueCommand(iota)
)

type renderQueueItem struct {
    command queueCommand
    w http.ResponseWriter
    req *http.Request
    complete chan<- bool
}

func launchRenderService() (func(http.ResponseWriter, *http.Request), chan<- renderQueueItem) {

    // Handle 1024 render requests without waiting
    input := make(chan renderQueueItem, libgodelbrot.Kilo)

    go handleRenderRequests(input)

    return httpChanWriter(input), input
}

func httpChanWriter(input chan<- renderQueueItem) func(http.ResponseWriter, *http.Request) {
    return func (w http.ResponseWriter, req *http.Request) {
        done := make(chan bool)
        input <- renderQueueItem{
            command: queueRender, 
            w: w, 
            req: req,
            complete: done,
        }
        // Block until rendering is complete
        <- done
    }
}<commit_msg>Delete uninformative comment<commit_after>package main

import (
    "fmt"
    "net/http"
    "encoding/json"
    "time"
    "image/png"
    "log"
    "functorama.com/demo/libgodelbrot"
    "bytes"
    "runtime"
)

type WebCommand string
const (
    render = WebCommand("render")
    displayImage = WebCommand("displayImage")
)

type WebRenderParameters struct {
    ImageWidth uint
    ImageHeight uint
    RealMin float64
    RealMax float64
    ImagMin float64
    ImagMax float64
}

type RenderMetadata struct {
    Renderer string
    Palette string
    RenderDuration string
}

type GodelbrotPacket struct {
    Command WebCommand
    Render WebRenderParameters
    Metadata RenderMetadata
}

const godelbrotHeader string = "X-Godelbrot-Packet"
const godelbrotGetParam string = "godelbrotPacket"

type queueCommand uint

const (
    queueRender = queueCommand(iota)
    queueStop = queueCommand(iota)
)

type renderQueueItem struct {
    command queueCommand
    w http.ResponseWriter
    req *http.Request
    complete chan<- bool
}

func launchRenderService() (func(http.ResponseWriter, *http.Request), chan<- renderQueueItem) {
    input := make(chan renderQueueItem, libgodelbrot.Kilo)

    go handleRenderRequests(input)

    return httpChanWriter(input), input
}

func httpChanWriter(input chan<- renderQueueItem) func(http.ResponseWriter, *http.Request) {
    return func (w http.ResponseWriter, req *http.Request) {
        done := make(chan bool)
        input <- renderQueueItem{
            command: queueRender, 
            w: w, 
            req: req,
            complete: done,
        }
        // Block until rendering is complete
        <- done
    }
}
{'fraction_non_alphanumeric': 0.08075449454759799, 'fraction_numerical': 0.0058944886531093425, 'mean_word_length': 2.9511059371362047, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 3, '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': '127993', 'n_tokens_mistral': 1036, 'n_tokens_neox': 990, 'n_words': 262}