pulsarKit

package
v1.3.14 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2023 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UrlPrefix = "pulsar://"
)

Variables

View Source
var (
	NotSetupError = errorKit.Simple("hasn't been set up")
)

Functions

func GetTag

func GetTag(msg pulsar.Message) string

GetTag

@param msg 不能为nil @return 可能为""

func MustSetUp added in v1.3.11

func MustSetUp(config *Config)

func NewClient

func NewClient(addresses []string, logPath string) (pulsar.Client, error)

func SetTag

func SetTag(pMsg *pulsar.ProducerMessage, tag string)

SetTag

@param pMsg 不能为nil @param tag 可以为""

func SetUp added in v1.3.11

func SetUp(pulsarConfig *Config) (err error)

Types

type Config

type Config struct {
	// Addresses Broker地址
	Addresses []string `json:"addresses"`

	VerifyConfig *VerifyConfig `json:"verify"`
}

type Consumer added in v1.3.11

type Consumer struct {
	pulsar.Client
	pulsar.Consumer
}

func NewConsumer added in v1.3.11

func NewConsumer(ctx context.Context, options pulsar.ConsumerOptions, logPath string) (*Consumer, error)

NewConsumer

前提: 成功调用 SetUp() || MustSetUp().

@param options 至少需要为 Topic、SubscriptionName、Type 属性复制 @param logPath 客户端的日志输出(为空则输出到控制台)

func NewConsumerOriginally added in v1.3.11

func NewConsumerOriginally(ctx context.Context, addresses []string, options pulsar.ConsumerOptions, logPath string) (*Consumer, error)

NewConsumerOriginally

PS: 目标Pulsar服务未启动的情况下,如果ctx不加以限制,要过约 1min 才会返回error(期间客户端日志有connection refused输出).

@param options 必须的属性: Topic、SubscriptionName、Type @param logPath 客户端的日志输出(为空则输出到控制台)

func (*Consumer) Close added in v1.3.11

func (c *Consumer) Close()

type Producer added in v1.3.11

type Producer struct {
	pulsar.Client
	pulsar.Producer
}

func NewProducer added in v1.3.11

func NewProducer(ctx context.Context, options pulsar.ProducerOptions, logPath string) (*Producer, error)

NewProducer

前提: 成功调用 SetUp() || MustSetUp().

@param logPath 客户端的日志输出(为空则输出到控制台)

func NewProducerOriginally added in v1.3.11

func NewProducerOriginally(ctx context.Context, addresses []string, options pulsar.ProducerOptions, logPath string) (*Producer, error)

NewProducerOriginally

PS: 目标Pulsar服务未启动的情况下,如果ctx不加以限制,要过约 1min 才会返回error(期间客户端日志有connection refused输出).

@param options 必须的属性: Topic

建议的属性: SendTimeout

@param logPath 客户端的日志输出(为空则输出到控制台)

func (*Producer) Close added in v1.3.11

func (p *Producer) Close()

type VerifyConfig added in v1.3.11

type VerifyConfig struct {
	// Topic 用于验证"pulsar服务是否正常启动"的topic
	Topic string `json:"topic"`
	// Print 是否输出 验证日志 到控制台?
	Print bool `json:"print"`
}

Jump to

Keyboard shortcuts

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