<commit_before>package consumer

import (
	"log"
	"github.com/satori/go.uuid"
	"github.com/streadway/amqp"
)

type Consumer struct {
	uri string
	exchangeName string
	conn *amqp.Connection
	ch *amqp.Channel
	Deliveries <-chan amqp.Delivery
}

func New(uri string, exchangeName string) *Consumer {
	c := &Consumer{}
	c.uri = uri
	c.exchangeName = exchangeName

	return c
}

func (c *Consumer) Start() (err error) {
	c.conn, c.ch, err = c.openChannel()

	q, err := c.createExpirableQueue(c.ch)

    c.Deliveries, err = c.ch.Consume(q.Name, "", true, false, false, false, nil)

    return err
}

func (c *Consumer) Stop() {
    c.conn.Close()
    c.ch.Close()
}

func (c *Consumer) openChannel() (*amqp.Connection, *amqp.Channel, error) {
	
	var conn *amqp.Connection
	var ch *amqp.Channel
	var err error

    log.Printf("Establishing connection... "+ c.uri)
    conn, err = amqp.Dial(c.uri)
    log.Printf("Connected")

    if err != nil {
	    log.Printf("Fail connecting")

    	return conn, ch, err
    }

    ch, err = conn.Channel()
    log.Printf("Channel opened")
    if err != nil {
	    log.Printf("Fail opening channel")
    }

    return conn, ch, err
}

func (c *Consumer) createExpirableQueue(ch *amqp.Channel) (amqp.Queue, error) {
    var args amqp.Table
    args = make(amqp.Table)
    args["x-expires"] = int32(10000)

    q, err := ch.QueueDeclare(
      "tailmq_"+uuid.NewV4().String(), // name
      false,   // durable
      true,    // delete when unused
      false,   // exclusive
      false,   // no-wait
      args,    // arguments
    )

    if err != nil {
	    log.Printf("Fail declaring queue")
    	return q, err
    }

    err = ch.QueueBind(
      q.Name, // name
      "#",   // routing key
      c.exchangeName,   // exchange name
      false,   // exclusive
      nil,     // arguments
    )

    if err != nil {
	    log.Printf("Fail binding queue")
		return q, err
    }

    err = ch.QueueBind(
      q.Name, // name
      "",   // routing key
      c.exchangeName,   // exchange name
      false,   // exclusive
      nil,     // arguments
    )

    if err != nil {
	    log.Printf("Fail binding queue")
		return q, err
    }

    log.Printf("Queue defined")

    return q, err
}<commit_msg>Remove logging<commit_after>package consumer

import (
	"log"
	"github.com/satori/go.uuid"
	"github.com/streadway/amqp"
)

type Consumer struct {
	uri string
	exchangeName string
	conn *amqp.Connection
	ch *amqp.Channel
	Deliveries <-chan amqp.Delivery
}

func New(uri string, exchangeName string) *Consumer {
	c := &Consumer{}
	c.uri = uri
	c.exchangeName = exchangeName

	return c
}

func (c *Consumer) Start() (err error) {
	c.conn, c.ch, err = c.openChannel()

	q, err := c.createExpirableQueue(c.ch)

    c.Deliveries, err = c.ch.Consume(q.Name, "", true, false, false, false, nil)

    return err
}

func (c *Consumer) Stop() {
    c.conn.Close()
    c.ch.Close()
}

func (c *Consumer) openChannel() (*amqp.Connection, *amqp.Channel, error) {
	
    log.Printf("Establishing connection... "+ c.uri)
    conn, err := amqp.Dial(c.uri)
    log.Printf("Connected")

    ch, err := conn.Channel()
    log.Printf("Channel opened")

    return conn, ch, err
}

func (c *Consumer) createExpirableQueue(ch *amqp.Channel) (amqp.Queue, error) {
    var args amqp.Table
    args = make(amqp.Table)
    args["x-expires"] = int32(10000)

    q, err := ch.QueueDeclare(
      "tailmq_"+uuid.NewV4().String(), // name
      false,   // durable
      true,    // delete when unused
      false,   // exclusive
      false,   // no-wait
      args,    // arguments
    )

    err = ch.QueueBind(
      q.Name, // name
      "#",   // routing key
      c.exchangeName,   // exchange name
      false,   // exclusive
      nil,     // arguments
    )

    err = ch.QueueBind(
      q.Name, // name
      "",   // routing key
      c.exchangeName,   // exchange name
      false,   // exclusive
      nil,     // arguments
    )

    log.Printf("Queue defined")

    return q, err
}
{'fraction_non_alphanumeric': 0.14310733049787341, 'fraction_numerical': 0.0040030022516887665, 'mean_word_length': 2.2743652743652745, 'pattern_counts': {'":': 0, '<': 5, '<?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': '7350183', 'n_tokens_mistral': 1430, 'n_tokens_neox': 1385, 'n_words': 348}