sarama

package
v0.0.0-...-75a017b Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

https://github.com/Shopify/sarama/tree/main/examples/sasl_scram_client

Index

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 Produce

func Produce(addr, topic, msg string, config *sarama.Config) error

Produce 循环5s生产消息,topic会自动创建 config如果传nil,会自动创建配置

func SASLConfig

func SASLConfig(user, pass string) *sarama.Config

SASLConfig 简单认证配置 Simple Authentication and Security Layer

func SCRAMSha256

func SCRAMSha256(c *sarama.Config)

SCRAMSha256 SCRAM-SHA-256 认证机制

func SCRAMSha512

func SCRAMSha512(c *sarama.Config)

SCRAMSha512 SCRAM-SHA-512 认证机制

Types

type ConsumerGroupHandler

type ConsumerGroupHandler struct {
	// 消费单条消息
	Consume func(*sarama.ConsumerMessage)
}

ConsumerGroupHandler 处理单个分区 实现sarama.ConsumerGroupHandler接口,方法会被并发调用

func (ConsumerGroupHandler) Cleanup

Cleanup 处理结束清理

func (ConsumerGroupHandler) ConsumeClaim

ConsumeClaim 处理消息

func (ConsumerGroupHandler) Setup

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 生成客户端

func (*SCRAMClient) Done

func (x *SCRAMClient) Done() bool

Done scram会话是否结束

func (*SCRAMClient) Step

func (x *SCRAMClient) Step(challenge string) (response string, err error)

Step 执行scram交换

Jump to

Keyboard shortcuts

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