transport

package
v0.0.0-...-3153823 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2020 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package transport 同步通信

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrTimeout 超时
	ErrTimeout = errors.New("timeout")
)

Functions

This section is empty.

Types

type HandleFunc

type HandleFunc func(sessionID network.SessionID, messageID network.MessageID, payload []byte) ([]byte, error)

HandleFunc 被动接收消息后的处理函数

type Transport

type Transport interface {
	// Push 发送消息,同步,阻塞,返回错误
	Push(topic string, sessionID network.SessionID, messageID network.MessageID, payload []byte) error

	// Request 发送消息,同步,阻塞,返回响应和错误
	Request(topic string, sessionID network.SessionID, messageID network.MessageID, payload []byte, timeout time.Duration) ([]byte, error)

	// SubscribeQueue 订阅消息。多个服务订阅同一个 topic 时,只有一个会获取到消息
	// 收到消息后,调用 handle 进行处理
	SubscribeQueue(topic string, handle HandleFunc) error

	// Subscribe 订阅消息。当多个服务器订阅同一个消息时,他们都会获取到消息
	// 收到消息后,调用 handle 进行处理
	Subscribe(topic string, handle HandleFunc)

	// Close 关闭
	Close() error
}

Transport 同步通信接口

Directories

Path Synopsis
Package nats 封装同步通信
Package nats 封装同步通信

Jump to

Keyboard shortcuts

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