<commit_before>package main

import (
	"encoding/json"
	"flag"
	"log"

	amqp "github.com/replaygaming/amqp-consumer"
)

var (
	env         = flag.String("env", "development", "Environment: development or production")
	amqpURL     = flag.String("amqp-url", "amqp://guest:guest@localhost:5672/metrics", "AMQP URL")
	gaGameKey   = flag.String("ga-game-key", "", "GameAnalytics GameKey")
	gaSecretKey = flag.String("ga-secret-key", "", "GameAnalytics SecretKey")
)

// Event contains the generic information received from Replay Poker
type Event struct {
	Version   uint
	Type      string `json:"event"`
	UserID    string `json:"user_id"`
	Timestamp string
	Session   struct {
		UUID   string `json:"uuid"`
		Number uint
	}
	Properties json.RawMessage
}

// Adapter is the interface required to start a new service to receive incoming
// events and forward them to the correct API
type Adapter interface {
	Start() (chan<- Event, error)
}

func init() {
	flag.Parse()
}

func main() {
	// Start consumer queue
	c, err := amqp.NewConsumer(*amqpURL, "metrics_ex", "fanout", "", "", "metrics")
	if err != nil {
		log.Fatalf("[FATAL] AMQP consumer failed %s", err)
	}
	messages, err := c.Consume("")
	if err != nil {
		log.Fatalf("[FATAL] AMQP queue failed %s", err)
	}

	// Start event adapters
	ga := &GameAnalytics{
		GameKey:     *gaGameKey,
		SecretKey:   *gaSecretKey,
		Environment: *env,
	}
	adapters := []Adapter{ga}
	chans := make([]chan<- Event, len(adapters))

	for i, a := range adapters {
		c, err := a.Start()
		if err != nil {
			log.Fatalf("[FATAL] Adapter failed to start %s", err)
		}
		chans[i] = c
	}

	// Listen for incoming events
	for m := range messages {
		e := &Event{}
		err := json.Unmarshal(m.Body, e)
		if err != nil {<commit_msg>Define queue name for the service<commit_after>package main

import (
	"encoding/json"
	"flag"
	"log"

	amqp "github.com/replaygaming/amqp-consumer"
)

var (
	env         = flag.String("env", "development", "Environment: development or production")
	amqpURL     = flag.String("amqp-url", "amqp://guest:guest@localhost:5672/metrics", "AMQP URL")
	amqpQueue   = flag.String("amqp-queue", "metrics", "AMQP Queue name")
	gaGameKey   = flag.String("ga-game-key", "", "GameAnalytics GameKey")
	gaSecretKey = flag.String("ga-secret-key", "", "GameAnalytics SecretKey")
)

// Event contains the generic information received from Replay Poker
type Event struct {
	Version   uint
	Type      string `json:"event"`
	UserID    string `json:"user_id"`
	Timestamp string
	Session   struct {
		UUID   string `json:"uuid"`
		Number uint
	}
	Properties json.RawMessage
}

// Adapter is the interface required to start a new service to receive incoming
// events and forward them to the correct API
type Adapter interface {
	Start() (chan<- Event, error)
}

func init() {
	flag.Parse()
}

func main() {
	// Start consumer queue
	c, err := amqp.NewConsumer(*amqpURL, "metrics_ex", "fanout", *amqpQueue, "", "metrics")
	if err != nil {
		log.Fatalf("[FATAL] AMQP consumer failed %s", err)
	}
	messages, err := c.Consume(*amqpQueue)
	if err != nil {
		log.Fatalf("[FATAL] AMQP queue failed %s", err)
	}

	// Start event adapters
	ga := &GameAnalytics{
		GameKey:     *gaGameKey,
		SecretKey:   *gaSecretKey,
		Environment: *env,
	}
	adapters := []Adapter{ga}
	chans := make([]chan<- Event, len(adapters))

	for i, a := range adapters {
		c, err := a.Start()
		if err != nil {
			log.Fatalf("[FATAL] Adapter failed to start %s", err)
		}
		chans[i] = c
	}

	// Listen for incoming events
	for m := range messages {
		e := &Event{}
		err := json.Unmarshal(m.Body, e)
		if err != nil {
{'fraction_non_alphanumeric': 0.14918350401328537, 'fraction_numerical': 0.0022142264046498754, 'mean_word_length': 3.6813471502590676, 'pattern_counts': {'":': 0, '<': 7, '<?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': '2151426', 'n_tokens_mistral': 1311, 'n_tokens_neox': 1254, 'n_words': 364}