<commit_before>﻿namespace Okanshi

open System
open System.Collections.Generic

module HealthChecks =
    let mutable private healthChecks = Map.empty

    /// Add a health check
    let Add (name : string, x : Func<bool>) =
        healthChecks <- healthChecks.Add (name, x)

    /// Check if a health check already exists
    let Exists (name) =
        name |> healthChecks.ContainsKey

    /// Clear all healthchecks
    let Clear() =
        healthChecks <- Map.empty

    /// Run all healthchecks defined
    let RunAll() =
        let dict = new Dictionary<string, bool>()
        healthChecks |> Map.iter (fun key value -> dict.Add(key, value.Invoke()))
        dict
<commit_msg>Convert HealthCheck module to be C# friendly<commit_after>﻿namespace Okanshi

open System
open System.Collections.Generic
open System.Collections.Concurrent

/// Handles healthchecks
[<AbstractClass; Sealed>]
type HealthChecks private () =
    static let mutable healthChecks = new ConcurrentDictionary<_, _>()

    /// Add a health check
    static member Add (name : string, x : Func<bool>) = healthChecks.TryAdd (name, x) |> ignore
    /// Check if a health check already exists
    static member Exists (name) = name |> healthChecks.ContainsKey
    /// Clear all healthchecks
    static member Clear() = healthChecks.Clear()
    /// Run all healthchecks defined
    static member RunAll() =
        let dict = new Dictionary<string, bool>()
        healthChecks.ToArray() |> Seq.iter (fun kvp -> dict.Add(kvp.Key, kvp.Value.Invoke()))
        dict

{'fraction_non_alphanumeric': 0.10526315789473684, 'fraction_numerical': 0.0, 'mean_word_length': 2.938618925831202, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 16, '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': '4862238', 'n_tokens_mistral': 443, 'n_tokens_neox': 430, 'n_words': 146}