<commit_before>package main

import (
	log "github.com/Sirupsen/logrus"
	"github.com/codegangsta/cli"
	"github.com/loadimpact/speedboat/client"
	"github.com/loadimpact/speedboat/master"
	"time"
)

func init() {
	registerCommand(cli.Command{
		Name:   "ping",
		Usage:  "Test command, will be removed",
		Action: actionPing,
	})
	registerHandler(handlePing)
}

func handlePing(m *master.Master, msg master.Message, out chan master.Message) bool {
	switch msg.Type {
	case "ping.ping":
		out <- master.Message{
			Type: "ping.pong",
			Body: msg.Body,
		}
		return true
	default:
		return false
	}
}

func actionPing(c *cli.Context) {
	client, err := client.New("tcp://127.0.0.1:9595", "tcp://127.0.0.1:9596")
	if err != nil {
		log.WithError(err).Fatal("Couldn't create a client")
	}

	in, out, errors := client.Connector.Run()
	out <- master.Message{
		Type: "ping.ping",
		Body: time.Now().Format("15:04:05 2006-01-02 MST"),
	}

	select {
	case reply := <-in:
		log.WithFields(log.Fields{
			"type": reply.Type,
			"body": reply.Body,
		}).Info("Reply")
	case err := <-errors:
		log.WithError(err).Error("Ping failed")
	}
}<commit_msg>Just ignore unknown messages<commit_after>package main

import (
	log "github.com/Sirupsen/logrus"
	"github.com/codegangsta/cli"
	"github.com/loadimpact/speedboat/client"
	"github.com/loadimpact/speedboat/master"
	"time"
)

func init() {
	registerCommand(cli.Command{
		Name:   "ping",
		Usage:  "Test command, will be removed",
		Action: actionPing,
	})
	registerHandler(handlePing)
}

func handlePing(m *master.Master, msg master.Message, out chan master.Message) bool {
	switch msg.Type {
	case "ping.ping":
		out <- master.Message{
			Type: "ping.pong",
			Body: msg.Body,
		}
		return true
	default:
		return false
	}
}

func actionPing(c *cli.Context) {
	client, err := client.New("tcp://127.0.0.1:9595", "tcp://127.0.0.1:9596")
	if err != nil {
		log.WithError(err).Fatal("Couldn't create a client")
	}
	in, out, errors := client.Connector.Run()

	// Send a bunch of noise to filter through
	out <- master.Message{Type: "ping.noise"}
	out <- master.Message{Type: "ping.noise"}

	// Send a ping message, server should reply with a pong
	out <- master.Message{
		Type: "ping.ping",
		Body: time.Now().Format("15:04:05 2006-01-02 MST"),
	}

readLoop:
	for {
		select {
		case msg := <-in:
			switch msg.Type {
			case "ping.pong":
				log.WithFields(log.Fields{
					"body": msg.Body,
				}).Info("Pong!")
				break readLoop
			}
		case err := <-errors:
			log.WithError(err).Error("Ping failed")
		}
	}
}
{'fraction_non_alphanumeric': 0.16777996070726917, 'fraction_numerical': 0.026719056974459726, 'mean_word_length': 3.603978300180832, 'pattern_counts': {'":': 6, '<': 13, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 4, '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': '7608558', 'n_tokens_mistral': 1082, 'n_tokens_neox': 961, 'n_words': 209}