kafka

package
v0.7.13 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2026 License: BSD-2-Clause Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TopicMockNext              = "topic_mock_next"
	TopicUpload                = "topic_upload"
	TypeOfStructInMessageValue = "type_of_struct_in_value"
)

Variables

View Source
var SHA256 scram.HashGeneratorFcn = func() hash.Hash { return sha256.New() }

SHA256 is a hash generator function for SCRAM-SHA-256.

View Source
var SHA512 scram.HashGeneratorFcn = func() hash.Hash { return sha512.New() }

SHA512 is a hash generator function for SCRAM-SHA-512.

Functions

func CommonProducerConfig

func CommonProducerConfig(cfg *model.Cfg) (*sarama.Config, error)

CommonProducerConfig returns a new Kafka producer configuration instance with sane defaults for vc.

Types

type Consumer

type Consumer interface {
	Start(handlerFactory func(string) sarama.ConsumerGroupHandler) error
	Close(ctx context.Context) error
}

type ConsumerGroupHandler

type ConsumerGroupHandler struct {
	Handlers map[string]MessageHandler
	Log      *logger.Log
}

ConsumerGroupHandler struct that handles Kafka group handlers

func (*ConsumerGroupHandler) Cleanup

func (*ConsumerGroupHandler) ConsumeClaim

func (*ConsumerGroupHandler) Setup

type HandlerConfig

type HandlerConfig struct {
	Topic         string
	ConsumerGroup string
}

HandlerConfig struct to define the Kafka topic and consumer group for a specific message handler

type MessageConsumerClient

type MessageConsumerClient struct {
	SaramaConfig *sarama.Config
	// contains filtered or unexported fields
}

MessageConsumerClient ATTENTION: Start max one instance of consumer client for each service to keep resource usage low

func NewConsumerClient

func NewConsumerClient(ctx context.Context, cfg *model.Cfg, brokers []string, log *logger.Log) (*MessageConsumerClient, error)

func (*MessageConsumerClient) Close

Close closes the consumer client

func (*MessageConsumerClient) Start

func (c *MessageConsumerClient) Start(ctx context.Context, handlerFactory func(string) sarama.ConsumerGroupHandler, handlerConfigs []HandlerConfig) error

Start starts the actual event consuming from specified kafka topics

type MessageHandler

type MessageHandler interface {
	HandleMessage(ctx context.Context, message *sarama.ConsumerMessage) error
}

MessageHandler definition of a generic Kafka message handler

type SyncProducerClient

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

MessageConsumerClient ATTENTION: Start max one instance of Kafka consumer client for each service to keep resource usage low

func NewSyncProducerClient

func NewSyncProducerClient(ctx context.Context, saramaConfig *sarama.Config, cfg *model.Cfg, tracer *trace.Tracer, log *logger.Log) (*SyncProducerClient, error)

NewSyncProducerClient creates a Kafka sync producer client

func (*SyncProducerClient) Close

func (c *SyncProducerClient) Close(ctx context.Context) error

Close close the producer

func (*SyncProducerClient) PublishMessage

func (c *SyncProducerClient) PublishMessage(topic string, key string, json []byte, headers []sarama.RecordHeader) error

PublishMessage publish a message to a Kafka topic

type XDGSCRAMClient added in v0.6.4

type XDGSCRAMClient struct {
	*scram.ClientConversation
	scram.HashGeneratorFcn
}

XDGSCRAMClient implements the sarama.SCRAMClient interface using xdg-go/scram.

func (*XDGSCRAMClient) Begin added in v0.6.4

func (x *XDGSCRAMClient) Begin(userName, password, authzID string) (err error)

Begin starts a new SCRAM conversation.

func (*XDGSCRAMClient) Done added in v0.6.4

func (x *XDGSCRAMClient) Done() bool

Done returns true if the conversation is complete.

func (*XDGSCRAMClient) Step added in v0.6.4

func (x *XDGSCRAMClient) Step(challenge string) (response string, err error)

Step advances the SCRAM conversation by one step.

Jump to

Keyboard shortcuts

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