prioritymq

package
v0.0.0-...-eaea552 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DummyLogger = LoggerFunc(func(string, ...interface{}) {})

DummyLogger dummy logger writes nothing.

Functions

func NewTopicName

func NewTopicName(name string, l Level) string

NewTopicName 创建优先级topic名字 格式: xxx-high,xxx-medium,xxx-low,xxx-normal

func Recovery

func Recovery(logger Logger)

Recovery catch go runtime panic

Types

type Level

type Level int64

Level 队列优先级

const (
	// Normal 普通优先级
	Normal Level = iota

	// Low 低优先级
	Low

	// Medium 中优先级
	Medium

	// High 高优先级
	High
)

type Logger

type Logger interface {
	Printf(string, ...interface{})
}

Logger is logger interface.

type LoggerFunc

type LoggerFunc func(string, ...interface{})

LoggerFunc is a bridge between Logger and any third party logger.

func (LoggerFunc) Printf

func (f LoggerFunc) Printf(msg string, args ...interface{})

Printf implements Logger interface.

type MQ

type MQ interface {
	// Publish 发送消息
	Publish(ctx context.Context, topic string, msg []byte, opts ...PubOption) error

	// Subscribe 消费消息
	Subscribe(ctx context.Context, topics []string, channel string, subHandler SubHandler, opts ...SubOption) error

	// Shutdown 平滑退出
	Shutdown(ctx context.Context) error
}

MQ 优先级队列接口

type PubOption

type PubOption func(p *PublishOptions)

PubOption option for producer

func WithPubName

func WithPubName(key string) PubOption

WithPubName set publish name

type PublishOptions

type PublishOptions struct {
	Key string
}

PublishOptions publish options

type SubHandler

type SubHandler func(ctx context.Context, msg []byte) error

SubHandler subscribe func

type SubOption

type SubOption func(s *SubscribeOptions)

SubOption subscribe option

func WithBufferSize

func WithBufferSize(size int) SubOption

WithBufferSize set priority mq buffer size

func WithCommitOffsetBlock

func WithCommitOffsetBlock(commitOffsetBlock bool) SubOption

WithCommitOffsetBlock set consumerGroup commitOffsetBlock

func WithSubName

func WithSubName(name string) SubOption

WithSubName set sub name

type SubscribeOptions

type SubscribeOptions struct {
	// specifies the consumer name
	// for kafka name eq group_id
	Name string

	// priority consumer buffer size
	BufferSize int

	// Commit the offset to the backend for kafka
	// Note: calling Commit performs a blocking synchronous operation.
	CommitOffsetBlock bool
}

SubscribeOptions subscribe message option

Directories

Path Synopsis
Package backoff provides backoff functionality
Package backoff provides backoff functionality

Jump to

Keyboard shortcuts

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