msgstream

package
v0.11.1 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2016 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Err

type Err struct {
	Topic     string
	Partition int32
	Err       error
}

Err is what is provided to the user when an error occurs. It wraps an error and includes the topic and partition.

func (Err) Error

func (ce Err) Error() string

type Errors

type Errors []*Err

ConsumerErrors is a type that wraps a batch of errors and implements the Error interface. It can be returned from the PartitionConsumer's Close methods to avoid the need to manually drain errors when stopping.

func (Errors) Error

func (ce Errors) Error() string

type Factory

type Factory interface {
	// SpawnMessageStream creates a T instance for the given topic/partition
	// with the given offset. It will return an error if there is an instance
	// already consuming from the topic/partition.
	//
	// Offset can be a literal offset, or OffsetNewest or OffsetOldest. If
	// offset is smaller then the oldest offset then the oldest offset is
	// returned. If offset is larger then the newest offset then the newest
	// offset is returned. If offset is either sarama.OffsetNewest or
	// sarama.OffsetOldest constant, then the actual offset value is returned.
	// otherwise offset is returned.
	SpawnMessageStream(namespace *actor.ID, topic string, partition int32, offset int64) (T, int64, error)

	// Stop shuts down the consumer. It must be called after all child partition
	// consumers have already been closed.
	Stop()
}

Factory provides API to spawn message streams to that read message from topic partitions. It ensures that there is only on message stream for a particular topic partition at a time.

func SpawnFactory

func SpawnFactory(namespace *actor.ID, client sarama.Client) (Factory, error)

SpawnFactory creates a new message stream factory using the given client. It is still necessary to call Stop() on the underlying client after shutting down this factory.

type T

type T interface {
	// Messages returns the read channel for the messages that are fetched from
	// the topic partition.
	Messages() <-chan *consumer.Message

	// Errors returns a read channel of errors that occurred during consuming,
	// if enabled. By default, errors are logged and not returned over this
	// channel. If you want to implement any custom error handling, set your
	// config's Consumer.Return.Errors setting to true, and read from this
	// channel.
	Errors() <-chan *Err

	// Stop synchronously stops the partition consumer. It must be called
	// before the factory that created the instance can be stopped.
	Stop()
}

T fetched messages from a given topic and partition.

Jump to

Keyboard shortcuts

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