kafka

package
v0.1.0-beta.0 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2020 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package kafka contains repositories backed by Kafka.

Index

Constants

View Source
const MessageSchema = `` /* 310-byte string literal not displayed */

MessageSchema is represents an Avro serialized Message.

Variables

This section is empty.

Functions

func NewMessageRepository

func NewMessageRepository(client *Client) (auth.MessageRepository, error)

NewMessageRepository returns a new implementation of auth.MessageRepository.

Types

type Client

type Client struct {
	OTPReader Reader
	OTPWriter Writer
}

Client contains a pair of Kafka reader and writers for every topic we are interested in.

func NewClient

func NewClient(brokers []string) *Client

NewClient returns a new Client.

type MessageRepository

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

MessageRepository allows us to read and write to an OTP Kafka topic.

func (*MessageRepository) Publish

func (r *MessageRepository) Publish(ctx context.Context, msg *auth.Message) error

Publish writes a message to topic `authenticator.messages.otp`.

func (*MessageRepository) Recent

func (r *MessageRepository) Recent(ctx context.Context) (<-chan *auth.Message, <-chan error)

Recent retrieves messages recently written to `authenticator.messages.otp`.

type Reader

type Reader interface {
	ReadMessage(ctx context.Context) (kafkaLib.Message, error)
}

Reader exposes kafka-go's reader API.

type Writer

type Writer interface {
	WriteMessages(ctx context.Context, msgs ...kafkaLib.Message) error
}

Writer exposes kafka-go's writer API.

Jump to

Keyboard shortcuts

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