Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How kq.NewPusher sets the access username and password for Kafa #3816

Open
bCoder778 opened this issue Dec 27, 2023 · 1 comment
Open

How kq.NewPusher sets the access username and password for Kafa #3816

bCoder778 opened this issue Dec 27, 2023 · 1 comment

Comments

@bCoder778
Copy link

When I added a password to Kafa's access, the creation of the pusher did not find the parameter to set the password, resulting in the pusher not working. I want to know where to set the password for access

@ljluestc
Copy link

package main

import (
    "github.com/Shopify/sarama"
    // Assuming kq is your package which includes NewPusher
    "kq"
)

func main() {
    // Configuration for Kafka
    config := sarama.NewConfig()
    config.Net.SASL.Enable = true
    config.Net.SASL.User = "your_username"
    config.Net.SASL.Password = "your_password"
    config.Net.SASL.Mechanism = sarama.SASLTypePlaintext // Use PLAIN mechanism, adjust as necessary

    // Broker addresses
    brokers := []string{"localhost:9092"}

    // Create a new client with the configured settings
    client, err := sarama.NewClient(brokers, config)
    if err != nil {
        panic(err)
    }
    defer client.Close()

    // Assuming NewPusher takes a client or configuration. Adjust according to actual function signature:
    pusher, err := kq.NewPusher(client)
    if err != nil {
        panic(err)
    }
    // Use your pusher
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants