unifrost: github.com/unifrost/unifrost/drivers/kafkadriver Index | Files

package kafkadriver

import "github.com/unifrost/unifrost/drivers/kafkadriver"


Package Files


type Client Uses

type Client struct {
    // contains filtered or unexported fields

Client handles the subscriptions to Kafka broker topics

func NewClient Uses

func NewClient(
    ctx context.Context,
    brokers []string,
    groupID string,
    config *sarama.Config,
    opts ...Option,
) (*Client, error)

NewClient returns *kafkadriver.Client, also connects to the kafka cluster.

This driver uses https://github.com/Shopify/sarama internally to connect to kafka brokers. A slice of broker addresses are required by sarama to connect to the kafka cluster, specify only one if single node. Configuration is handled bysarama.Config to subscribe to a kafka topic. https://godoc.org/github.com/Shopify/sarama#Config groupID is consumer group id. Additional configuration options can be added with kafkadriver.Option functions.

func (*Client) Close Uses

func (client *Client) Close(ctx context.Context) error

Close is just a placeholder

func (*Client) Subscribe Uses

func (client *Client) Subscribe(ctx context.Context, topic string) (*pubsub.Subscription, error)

Subscribe method subscribes to the kafka topic

type Option Uses

type Option func(*Client) error

Option is a self-refrential function for configuration parameters

Package kafkadriver imports 4 packages (graph). Updated 2020-03-03. Refresh now. Tools for package owners.