Documentation ¶
Index ¶
- Variables
- type Ack
- type Set
- type T
- func (p *T) Ack(group, topic string, ack Ack) error
- func (p *T) AsyncProduce(topic string, key, message sarama.Encoder, headers []sarama.RecordHeader)
- func (p *T) Consume(group, topic string, ack Ack) (consumer.Message, error)
- func (p *T) GetAllTopicConsumers(topic string) (map[string]map[string][]int32, error)
- func (p *T) GetGroupOffsets(group, topic string) ([]admin.PartitionOffset, error)
- func (p *T) GetTopicConsumers(group, topic string) (map[string][]int32, error)
- func (p *T) GetTopicMetadata(topic string, withPartitions, withConfig bool) (admin.TopicMetadata, error)
- func (p *T) ListTopics(withPartitions, withConfig bool) ([]admin.TopicMetadata, error)
- func (p *T) Produce(topic string, key, message sarama.Encoder, headers []sarama.RecordHeader) (*sarama.ProducerMessage, error)
- func (p *T) SetGroupOffsets(group, topic string, offsets []admin.PartitionOffset) error
- func (p *T) Stop()
Constants ¶
This section is empty.
Variables ¶
var ( ErrDisabled = errors.New("service is disabled by configuration") ErrHeadersUnsupported = errors.New("headers are not supported with this version of Kafka. Consider changing `kafka.version` (https://github.com/mailgun/kafka-pixy/blob/master/default.yaml#L35)") )
Functions ¶
This section is empty.
Types ¶
type Ack ¶ added in v0.13.0
type Ack struct {
// contains filtered or unexported fields
}
func AutoAck ¶ added in v0.13.0
func AutoAck() Ack
AutoAck returns an ack value that should be passed to proxy.Consume function when a caller wants the consumed message to be acknowledged immediately.
type Set ¶
type Set struct {
// contains filtered or unexported fields
}
Set represents a collection of proxy.T instances with a default value.
type T ¶
type T struct {
// contains filtered or unexported fields
}
T implements a proxy to a particular Kafka/ZooKeeper cluster.
func (*T) AsyncProduce ¶
AsyncProduce is an asynchronously counterpart of the `Produce` function. Errors are silently ignored.
func (*T) Consume ¶
Consume consumes a message from the specified topic on behalf of the specified consumer group. If there are no more new messages in the topic at the time of the request then it will block for `Config.Consumer.LongPollingTimeout`. If no new message is produced during that time, then `ErrRequestTimeout` is returned.
Note that during state transitions topic subscribe<->unsubscribe and consumer group register<->deregister the method may return either `ErrBufferOverflow` or `ErrRequestTimeout` even when there are messages available for consumption. In that case the user should back off a bit and then repeat the request.
func (*T) GetAllTopicConsumers ¶
GetAllTopicConsumers returns group -> client-id -> consumed-partitions-list mapping for a particular topic. Warning, the function performs scan of all consumer groups registered in ZooKeeper and therefore can take a lot of time.
func (*T) GetGroupOffsets ¶
func (p *T) GetGroupOffsets(group, topic string) ([]admin.PartitionOffset, error)
GetGroupOffsets for every partition of the specified topic it returns the current offset range along with the latest offset and metadata committed by the specified consumer group.
func (*T) GetTopicConsumers ¶
GetTopicConsumers returns client-id -> consumed-partitions-list mapping for a clients from a particular consumer group and a particular topic.
func (*T) GetTopicMetadata ¶ added in v0.14.0
func (p *T) GetTopicMetadata(topic string, withPartitions, withConfig bool) (admin.TopicMetadata, error)
GetTopicMetadata returns a topic metadata. An optional partition metadata can be requested and/or detailed topic configuration can be requested.
func (*T) ListTopics ¶ added in v0.14.0
func (p *T) ListTopics(withPartitions, withConfig bool) ([]admin.TopicMetadata, error)
ListTopics returns a list of all topics existing in the Kafka cluster.
func (*T) Produce ¶
func (p *T) Produce(topic string, key, message sarama.Encoder, headers []sarama.RecordHeader) (*sarama.ProducerMessage, error)
Produce submits a message to the specified `topic` of the Kafka cluster using `key` to identify a destination partition. The exact algorithm used to map keys to partitions is implementation specific but it is guaranteed that it returns consistent results. If `key` is `nil`, then the message is placed into a random partition.
Errors usually indicate a catastrophic failure of the Kafka cluster, or missing topic if there cluster is not configured to auto create topics.
func (*T) SetGroupOffsets ¶
func (p *T) SetGroupOffsets(group, topic string, offsets []admin.PartitionOffset) error
SetGroupOffsets commits specific offset values along with metadata for a list of partitions of a particular topic on behalf of the specified group.