<commit_before>package cloudpelican

// @author <NAME>
// Tool for logging data to CloudPelican directly from Go

// Imports
import (
    "net/http"
    "log"
)

// Settings
const ENDPOINT string = "https://app.cloudpelican.com/api/push/pixel"

// Write a message
func LogMessage(token string, msg string) bool {
    // @todo Write seperate func for url assembly, encoding, etc
    // @todo Validate
    var res bool = requestAsync(ENDPOINT + "?t=" + token + "&f[msg]=" + msg)
    return res
}

// Request a sync
// @todo Make sure all are pushed to backend before application shuts down
func requestAsync(url string) bool {
    go func() {
        _, err := http.Get(url)
        log.Println(url)
	if err != nil {
            log.Printf("Error while forwarding data: %s\n", err)
        }
    }()
    return true
}
<commit_msg>Working on drain function<commit_after>package cloudpelican

// @author <NAME>
// Tool for logging data to CloudPelican directly from Go

// Imports
import (
    "net/http"
    "log"
)

// Settings
const ENDPOINT string = "https://app.cloudpelican.com/api/push/pixel"

// Monitor drain status
routineQuit chan int = make(chan int)
startCounter uint64 = uint64(0)
startCounterMux sync.Mutex
doneCounter uint64 = uint64(0)
doneCounterMux sync.Mutex

// Write a message
func LogMessage(token string, msg string) bool {
    // @todo Write seperate func for url assembly, encoding, etc
    // @todo Validate
    var res bool = requestAsync(ENDPOINT + "?t=" + token + "&f[msg]=" + msg)
    return res
}

// Drain: wait for all data pushes to finish
func Drain() bool {
    if startCounter > doneCounter {
        <-routineQuit
    }
}

// Request a sync
// @todo Make sure all are pushed to backend before application shuts down
func requestAsync(url string) bool {
    // Add counter
    startCounterMux.Lock()
    startcounter++
    startCounterMux.Unlock()

    // Launch
    go func() {
        // Request url
        _, err := http.Get(url)
        log.Println(url)
	if err != nil {
            log.Printf("Error while forwarding data: %s\n", err)
        }

        // Done counter
        doneCounterMux.Lock()
        doneCounter++
        doneCounter.Unlock()
        // @todo Check whether dif between started and done is = 0, if so, drop a message in the routineQuit
    }()
    return true
}

{'fraction_non_alphanumeric': 0.11049011177987962, 'fraction_numerical': 0.004729148753224419, 'mean_word_length': 2.6416275430359937, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 6, 'https://': 2, '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': '1664532', 'n_tokens_mistral': 728, 'n_tokens_neox': 714, 'n_words': 241}