natsx

package
v1.2.49 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultNatsServer     = "127.0.0.1:4222"
	DefaultNatsServerIp   = "127.0.0.1"
	DefaultNatsServerPort = 4222
)

Variables

This section is empty.

Functions

This section is empty.

Types

type HFunc

type HFunc func(topic, reply string, data []byte)

type NatsClient

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

func NewNatsClient

func NewNatsClient(addr string) *NatsClient

func (*NatsClient) AddTopic

func (c *NatsClient) AddTopic(topic string, hFunc HFunc)

func (*NatsClient) AddTopics

func (c *NatsClient) AddTopics(topics map[string]HFunc)

func (*NatsClient) Push

func (c *NatsClient) Push(topic string, param *NatsMessage) error

func (*NatsClient) Push2

func (c *NatsClient) Push2(topic string, param interface{}) error

func (*NatsClient) Request

func (c *NatsClient) Request(topic string, param *NatsMessage) (*NatsMessageRsp, error)

func (*NatsClient) Response

func (c *NatsClient) Response(topic string, param *NatsMessageRsp) error

func (*NatsClient) Start

func (c *NatsClient) Start()

func (*NatsClient) Subscribe

func (c *NatsClient) Subscribe(topic string, h HFunc)

Subscribe 监听主题 必须在 Start 后

type NatsMessage

type NatsMessage struct {
	ReqCode   int         `json:"code,omitempty"`      //功能码
	Operation int         `json:"operation,omitempty"` //操作码
	ObjID     int         `json:"obj_id,omitempty"`    // 对象ID
	ProID     int         `json:"pro_id,omitempty"`    // 属性id
	Data      interface{} `json:"data,omitempty"`
}

type NatsMessageRsp

type NatsMessageRsp struct {
	ReqCode   int         `json:"code,omitempty"`      //功能码
	Operation int         `json:"operation,omitempty"` //操作码
	ObjId     int         `json:"obj_id,omitempty"`
	ProID     int         `json:"pro_id,omitempty"`
	ResCode   int         `json:"resCode,omitempty"` //执行状态
	ErrMsg    string      `json:"errMsg,omitempty"`  //执行错误信息
	Data      interface{} `json:"data,omitempty"`
}

Jump to

Keyboard shortcuts

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