kafka

package
v0.0.0-...-0420dee Latest Latest
Warning

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

Go to latest
Published: May 11, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Kafka package used by Pachamama Group, uses Segmentio Kafka.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type KafkaConsumer

type KafkaConsumer struct {
	Timeout time.Duration
	// contains filtered or unexported fields
}

func NewConsumer

func NewConsumer(broker, port, topic, groupID string, maxB int, logger *logger.AggregatedLogger, timeout time.Duration) *KafkaConsumer

func (*KafkaConsumer) Close

func (k *KafkaConsumer) Close() error

func (*KafkaConsumer) Read

func (k *KafkaConsumer) Read(p []byte) (n int, err error)

Read will output a JSON to P in the form of Message Struct

type KafkaProducer

type KafkaProducer struct {
	Timeout time.Duration
	// contains filtered or unexported fields
}

func NewProducer

func NewProducer(broker, port, topic string, logger *logger.AggregatedLogger, timeout time.Duration) *KafkaProducer

Context should have a timeout which will signal the time to read or write a message

func (*KafkaProducer) Write

func (k *KafkaProducer) Write(p []byte) (n int, err error)

Write expects p[]byte to be in the form of a JSON with a Key and Value from Message Struct.

type Message

type Message struct {
	Topic     string    `json:"topic"`
	Key       string    `json:"key"`
	Value     string    `json:"value"`
	Timestamp time.Time `json:"timestamp"`
}

Jump to

Keyboard shortcuts

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