<commit_before>package rabbitsmpp

import (
	"encoding/json"

	"github.com/streadway/amqp"
)

type Publisher interface {
	Publish(Job) error
	Client
}

type publisher struct {
	*client
}

func NewPublisher(conf Config) (Publisher, error) {
	c := NewClient(conf).(*client)
	return &publisher{c}, nil
}

func (p *publisher) Publish(j Job) error {
	ch, err := p.Channel()
	if err != nil {
		return err
	}
	defer ch.Close()

	q, err := ch.QueueDeclare(
		p.QueueName(), // name
		true,          // durable
		false,         // delete when unused
		false,         // exclusive
		false,         // no-wait
		nil,           // arguments
	)
	if err != nil {
		return err
	}

	bodyBytes, err := json.Marshal(j)
	if err != nil {
		return err
	}
	err = ch.Publish(
		"",     // exchange
		q.Name, // routing key
		false,  // mandatory
		false,  // immediate
		amqp.Publishing{<commit_msg>Do binding inside of Publish<commit_after>package rabbitsmpp

import (
	"encoding/json"

	"github.com/streadway/amqp"
)

type Publisher interface {
	Publish(Job) error
}

type publisher struct {
	*client
}

func NewPublisher(conf Config) (Publisher, error) {
	c := NewClient(conf).(*client)
	return &publisher{c}, nil
}

func (p *publisher) Publish(j Job) error {
	_, err := p.Bind()
	if err != nil {
		return err
	}

	ch, err := p.Channel()
	if err != nil {
		return err
	}
	defer ch.Close()

	q, err := ch.QueueDeclare(
		p.QueueName(), // name
		true,          // durable
		false,         // delete when unused
		false,         // exclusive
		false,         // no-wait
		nil,           // arguments
	)
	if err != nil {
		return err
	}

	bodyBytes, err := json.Marshal(j)
	if err != nil {
		return err
	}
	err = ch.Publish(
		"",     // exchange
		q.Name, // routing key
		false,  // mandatory
		false,  // immediate
		amqp.Publishing{
{'fraction_non_alphanumeric': 0.13789299503585217, 'fraction_numerical': 0.0, 'mean_word_length': 2.422641509433962, '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': '6476149', 'n_tokens_mistral': 691, 'n_tokens_neox': 643, 'n_words': 173}