producer

package
v0.2.3-0...-5ed8acd Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 26, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package producer holds interface for publishing messages to required destinations and implementation for sending messages to Kafka.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type KafkaProducer

type KafkaProducer struct {
	// contains filtered or unexported fields
}

KafkaProducer is a Producer implementation for publishing messages to Kafka

func (*KafkaProducer) Close

func (p *KafkaProducer) Close() error

Close closes Kafka connection

func (*KafkaProducer) Publish

func (p *KafkaProducer) Publish(msg Message) error

Publish publishes message to Kafka

type Message

type Message struct {
	ID    uuid.UUID `json:"id"`
	Body  []byte    `json:"body"`
	Topic string    `json:"topic"`
}

Message struct contains data for message read from RabbitMQ and ready for sending to Kafka

func NewMessage

func NewMessage(body []byte, topic string) *Message

NewMessage initializes and instantiates new Message

func (Message) String

func (m Message) String() string

String represents message as simple string value

type Producer

type Producer interface {
	Publish(msg Message) error
	Close() error
}

Producer is an interface for publishing messages service

func NewKafkaProducer

func NewKafkaProducer(kafkaConfig config.KafkaConfig, statsClient client.Client) (Producer, error)

NewKafkaProducer instantiates and establishes new Kafka connection

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL