<commit_before><commit_msg>Social/FollowingFeed: create an abstract consumer/listener for other workers<commit_after>package followingfeed

import (
	"fmt"
	"koding/messaging/rabbitmq"
	"socialapi/config"

	"github.com/streadway/amqp"
)

var (
	Consumer        *rabbitmq.Consumer
	WorkerQueueName = "FollowingFeedWorkerQueue"
	WorkerQueueTag  = "FollowingFeedWorkerConsumer"
)

func Listen(rmq *rabbitmq.RabbitMQ, startHandler func() func(delivery amqp.Delivery)) {
	exchange := rabbitmq.Exchange{
		Name:    config.EventExchangeName,
		Type:    "fanout",
		Durable: true,
	}

	queue := rabbitmq.Queue{
		Name:    WorkerQueueName,
		Durable: true,
	}

	binding := rabbitmq.BindingOptions{
		RoutingKey: "",
	}

	consumerOptions := rabbitmq.ConsumerOptions{
		Tag: WorkerQueueTag,
	}

	Consumer, err := rmq.NewConsumer(exchange, queue, binding, consumerOptions)
	if err != nil {
		fmt.Print(err)
		return
	}

	err = Consumer.QOS(10)
	if err != nil {
		panic(err)
	}

	Consumer.RegisterSignalHandler()
	Consumer.Consume(startHandler())
}
{'fraction_non_alphanumeric': 0.11594202898550725, 'fraction_numerical': 0.001932367149758454, 'mean_word_length': 4.630434782608695, 'pattern_counts': {'":': 0, '<': 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': '3310566', 'n_tokens_mistral': 384, 'n_tokens_neox': 345, 'n_words': 68}