mq

package
v1.1.3 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2022 License: Apache-2.0 Imports: 5 Imported by: 2

Documentation

Overview

Package mq 提供了标准的消息队列接口,可以灵活适配各种 MQ 实现。

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bind

func Bind(fn interface{}, topics ...string) *consumer

Bind 创建 Bind 方式的消费者。

func NewMessage

func NewMessage() *message

NewMessage 创建新的消息对象。

Types

type Consumer

type Consumer interface {
	Topics() []string
	Consume(ctx context.Context, msg Message) error
}

Consumer 消息消费者。

type Message

type Message interface {
	Topic() string
	ID() string
	Body() []byte
	Extra() map[string]string
}

type Producer

type Producer interface {

	// SendMessage 传入的消息类型不同用途也不同,需要分别判断。
	SendMessage(ctx context.Context, msg Message) error
}

Producer 消息生产者。

Jump to

Keyboard shortcuts

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