<commit_before><commit_msg>add outdated plugin<commit_after>package plugins

import (
	"fmt"
	"time"

	"github.com/InnovaCo/serve/manifest"
)

func init() {
	manifest.PluginRegestry.Add("outdated", Test{})
}

type Outdated struct{}

func (p Outdated) Run(data manifest.Manifest) error {
	consul, err := ConsulClient(data.GetString("consul-host"))
	if err != nil {
		return err
	}

	fullName := data.GetString("full-name")

	if existsRoutes, _, err := consul.KV().List("services/routes/"+fullName, nil); err == nil {
		for _, existsRoute := range existsRoutes {
			if err := delConsulKv(consul, existsRoute.Key); err != nil {
				return err
			}
		}
	}

	outdatedJson := fmt.Sprintf(`{"endOfLife":%d}`, time.Now().UnixNano()/int64(time.Millisecond))
	if err := putConsulKv(consul, "services/outdated/"+fullName, outdatedJson); err != nil {
		return err
	}

	return nil
}
{'fraction_non_alphanumeric': 0.1611047180667434, 'fraction_numerical': 0.0023014959723820483, 'mean_word_length': 4.54140127388535, 'pattern_counts': {'":': 1, '<': 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': '309224', 'n_tokens_mistral': 329, 'n_tokens_neox': 310, 'n_words': 64}