<commit_before>package main

import (
	"encoding/json"
	"io/ioutil"
	"time"

	"github.com/Sirupsen/logrus"
)

type GetConfigPayload struct {
	FromHostname string
	FromNodeID   string
	TimeStamp    int64
}

type ReturnConfigPayload struct {
	FromHostname  string
	FromNodeID    string
	Configuration MicroConfig
	TimeStamp     int64
}

type MicroConfig map[string]interface{}

func sanitizeConfig(mc MicroConfig) MicroConfig {

	sanitzeFields := []string{
		"secret",
		"node_secret",
		"storage",
		"slave_options",
		"auth_override",
	}

	for _, field_name := range sanitzeFields {
		delete(mc, field_name)
	}

	return mc
}

func getExistingConfig() (MicroConfig, error) {
	microConfig := MicroConfig{}
	dat, err := ioutil.ReadFile(usedConfPath)
	if err != nil {
		return microConfig, err
	}
	if err := json.Unmarshal(dat, &microConfig); err != nil {
		return microConfig, err
	}
	return sanitizeConfig(microConfig), nil
}

func handleSendMiniConfig(payload string) {
	// Decode the configuration from the payload
	configPayload := GetConfigPayload{}
	err := json.Unmarshal([]byte(payload), &configPayload)
	if err != nil {
		log.WithFields(logrus.Fields{
			"prefix": "pub-sub",
		}).Error("Failed unmarshal request: ", err)
		return
	}

	// Make sure payload matches nodeID and hostname
	if configPayload.FromHostname != HostDetails.Hostname && configPayload.FromNodeID != NodeID {
		log.WithFields(logrus.Fields{
			"prefix": "pub-sub",
		}).Debug("Configuration request received, no NodeID/Hostname match found, ignoring")
		return
	}

	config, err := getExistingConfig()
	if err != nil {<commit_msg>redis: remove MicroConfig type<commit_after>package main

import (
	"encoding/json"
	"io/ioutil"
	"time"

	"github.com/Sirupsen/logrus"
)

type GetConfigPayload struct {
	FromHostname string
	FromNodeID   string
	TimeStamp    int64
}

type ReturnConfigPayload struct {
	FromHostname  string
	FromNodeID    string
	Configuration map[string]interface{}
	TimeStamp     int64
}

func sanitizeConfig(mc map[string]interface{}) map[string]interface{} {

	sanitzeFields := []string{
		"secret",
		"node_secret",
		"storage",
		"slave_options",
		"auth_override",
	}

	for _, field_name := range sanitzeFields {
		delete(mc, field_name)
	}

	return mc
}

func getExistingConfig() (map[string]interface{}, error) {
	var microConfig map[string]interface{}
	dat, err := ioutil.ReadFile(usedConfPath)
	if err != nil {
		return microConfig, err
	}
	if err := json.Unmarshal(dat, &microConfig); err != nil {
		return microConfig, err
	}
	return sanitizeConfig(microConfig), nil
}

func handleSendMiniConfig(payload string) {
	// Decode the configuration from the payload
	configPayload := GetConfigPayload{}
	err := json.Unmarshal([]byte(payload), &configPayload)
	if err != nil {
		log.WithFields(logrus.Fields{
			"prefix": "pub-sub",
		}).Error("Failed unmarshal request: ", err)
		return
	}

	// Make sure payload matches nodeID and hostname
	if configPayload.FromHostname != HostDetails.Hostname && configPayload.FromNodeID != NodeID {
		log.WithFields(logrus.Fields{
			"prefix": "pub-sub",
		}).Debug("Configuration request received, no NodeID/Hostname match found, ignoring")
		return
	}

	config, err := getExistingConfig()
	if err != nil {
{'fraction_non_alphanumeric': 0.1169753086419753, 'fraction_numerical': 0.0024691358024691358, 'mean_word_length': 4.607266435986159, 'pattern_counts': {'":': 4, '<': 3, '<?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': '394688', 'n_tokens_mistral': 1119, 'n_tokens_neox': 1052, 'n_words': 263}