broker

package
v0.0.0-...-3c81578 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2019 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ChannelPub = 1 << iota
	ChannelSub
	ChannelRPC
	ChannelRPCServer
	AllChannel = ChannelPub | ChannelSub | ChannelRPC | ChannelRPCServer
)

Variables

View Source
var (
	ErrorTimeout = errors.New("timeout")
)

Functions

This section is empty.

Types

type RPCHandler

type RPCHandler func([]byte) []byte

type RabbitMQ

type RabbitMQ struct {
	// contains filtered or unexported fields
}

一个rabbit完整的Broker

func NewRabbitMQ

func NewRabbitMQ(cfg *RabbitMQConfig, rpcHandler RPCHandler) *RabbitMQ

新建rabbot通道,参数需要给定

func (*RabbitMQ) Close

func (rb *RabbitMQ) Close()

关闭

func (*RabbitMQ) ReceiveMessage

func (rb *RabbitMQ) ReceiveMessage() []byte

返回接收通道

func (*RabbitMQ) SendMessage

func (rb *RabbitMQ) SendMessage(node int, body []byte) error

异步发送消息 异步发送消息

func (*RabbitMQ) SyncMessage

func (rb *RabbitMQ) SyncMessage(node int, body []byte) ([]byte, error)

rpc 服务调用 同步发送等待返回

type RabbitMQConfig

type RabbitMQConfig struct {
	Node         int
	Url          string
	ExchangeName string
	ExchangeKind string
	ChanSize     int
	Channels     uint64
	RPCTimeout   time.Duration
	SendTimeout  time.Duration
	QueuePrefix  string // 队列前缀
}

rabbit配置

Jump to

Keyboard shortcuts

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