Documentation ¶
Overview ¶
https://github.com/Shopify/sarama/tree/main/examples/sasl_scram_client
Index ¶
- Constants
- func Consume(addr, groupId string, topics []string, f func(*sarama.ConsumerMessage), ...) error
- func Produce(addr, topic, msg string, config *sarama.Config) error
- func SASLConfig(user, pass string) *sarama.Config
- func SCRAMSha256(c *sarama.Config)
- func SCRAMSha512(c *sarama.Config)
- type ConsumerGroupHandler
- type ConsumerMessage
- type SCRAMClient
Constants ¶
View Source
const ( // SCRAM Salted Challenge Response Authentication Mechanism // SASLTypeSCRAMSha256 represents the SCRAM-SHA-256 mechanism. SASLTypeSCRAMSha256 = "SCRAM-SHA-256" // SASLTypeSCRAMSha512 represents the SCRAM-SHA-512 mechanism. SASLTypeSCRAMSha512 = "SCRAM-SHA-512" )
Variables ¶
This section is empty.
Functions ¶
func Consume ¶
func Consume( addr, groupId string, topics []string, f func(*sarama.ConsumerMessage), config *sarama.Config, ) error
Consume 使用消费者组消费,f为处理消息函数 config如果传nil,会自动创建配置
func SASLConfig ¶
SASLConfig 简单认证配置 Simple Authentication and Security Layer
Types ¶
type ConsumerGroupHandler ¶
type ConsumerGroupHandler struct { // 消费单条消息 Consume func(*sarama.ConsumerMessage) }
ConsumerGroupHandler 处理单个分区 实现sarama.ConsumerGroupHandler接口,方法会被并发调用
func (ConsumerGroupHandler) Cleanup ¶
func (ConsumerGroupHandler) Cleanup(_ sarama.ConsumerGroupSession) error
Cleanup 处理结束清理
func (ConsumerGroupHandler) ConsumeClaim ¶
func (h ConsumerGroupHandler) ConsumeClaim(s sarama.ConsumerGroupSession, claim sarama.ConsumerGroupClaim) error
ConsumeClaim 处理消息
func (ConsumerGroupHandler) Setup ¶
func (ConsumerGroupHandler) Setup(_ sarama.ConsumerGroupSession) error
Setup 处理之前初始化
type ConsumerMessage ¶
type ConsumerMessage = sarama.ConsumerMessage
type SCRAMClient ¶
type SCRAMClient struct { *scram.Client *scram.ClientConversation // 工厂函数,返回hash.Hash scram.HashGeneratorFcn }
SCRAMClient sarama.SCRAMClient实现
func (*SCRAMClient) Begin ¶
func (x *SCRAMClient) Begin(userName, password, authzID string) (err error)
Begin 生成客户端
Click to show internal directories.
Click to hide internal directories.