kafkabuff

package module
v0.0.0-...-1204eb5 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2024 License: Apache-2.0 Imports: 2 Imported by: 3

README

kafkabuff

kafkabuff is a thread-safe ring buffer implementation designed for efficient handling of Kafka messages

Features

  • Thread-safe operations for adding and retrieving messages.
  • Batch retrieval for efficient Kafka message processing.
  • Automatic overwriting of the oldest messages when the buffer is full.
  • Easy integration with Sarama Kafka client.

Installation

To use kafkabuff, simply run:

go get github.com/vagbundor/kafkabuff

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type RingBuffer

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

RingBuffer is a thread-safe circular buffer for storing Kafka messages

func NewRingBuffer

func NewRingBuffer(size int) *RingBuffer

NewRingBuffer creates a new ring buffer with the specified size.

func (*RingBuffer) Add

func (rb *RingBuffer) Add(msg *sarama.ProducerMessage)

Add inserts a new message into the buffer. If the buffer is full, it overwrites the oldest message.

func (*RingBuffer) GetBatch

func (rb *RingBuffer) GetBatch(batchSize int) []*sarama.ProducerMessage

GetBatch retrieves up to batchSize messages from the ring buffer.

func (*RingBuffer) Size

func (rb *RingBuffer) Size() int

Size returns the current number of messages in the buffer.

Jump to

Keyboard shortcuts

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