<commit_before>package input

import (
	certstream "github.com/CaliDog/certstream-go"
	log "github.com/Sirupsen/logrus"
	"github.com/jmoiron/jsonq"
)

// CertStreamInput provides a stream of Certificate Transparency Logs https://www.certificate-transparency.org/
// It's used for example purposes only and should NOT be used in production
// Since the stream is a websocket slow processing would result in memory pressure
// Instead the data should be pushed into a queue, such as Kinesis, and GoFish should read from that stream
type CertStreamInput struct {
	stream chan jsonq.JsonQuery
}

func (c *CertStreamInput) Init() error {
	c.stream = certstream.CertStreamEventStream(false)
	return nil
}

func (c *CertStreamInput) Retrieve(output *chan []byte) {
	defer close(*output)
	for i := range c.stream {
		json, err := i.String()
		if err != nil {
			log.Errorf("Invalid data from Cert Stream: %s", err)
			continue
		}
		*output <- []byte(json)
	}
}<commit_msg>Horrible hack, unmarshal the event so we can re-marshal it<commit_after>package input

import (
	"encoding/json"

	certstream "github.com/CaliDog/certstream-go"
	log "github.com/Sirupsen/logrus"
	"github.com/jmoiron/jsonq"
)

// CertStreamInput provides a stream of Certificate Transparency Logs https://www.certificate-transparency.org/
// It's used for example purposes only and should NOT be used in production
// Since the stream is a websocket slow processing would result in memory pressure
// Instead the data should be pushed into a queue, such as Kinesis, and GoFish should read from that stream
type CertStreamInput struct {
	stream chan jsonq.JsonQuery
}

func (c *CertStreamInput) Init() error {
	c.stream = certstream.CertStreamEventStream(false)
	return nil
}

func (c *CertStreamInput) Retrieve(output *chan []byte) {
	defer close(*output)
	for i := range c.stream {
		j, err := i.Object()
		if err != nil {
			log.Errorf("Invalid data from Cert Stream: %s", err)
			continue
		}
		data, err := json.Marshal(j)
		if err != nil {
			log.Errorf("Unable to Marshal Cert Stream: %s", err)
		}
		*output <- data
	}
}
{'fraction_non_alphanumeric': 0.10186513629842181, 'fraction_numerical': 0.0, 'mean_word_length': 4.114914425427873, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, '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': '6498229', 'n_tokens_mistral': 681, 'n_tokens_neox': 643, 'n_words': 233}