Documentation ¶
Index ¶
- Constants
- type HFunc
- type NatsClient
- func (c *NatsClient) AddTopic(topic string, hFunc HFunc)
- func (c *NatsClient) AddTopics(topics map[string]HFunc)
- func (c *NatsClient) Push(topic string, param *NatsMessage) error
- func (c *NatsClient) Push2(topic string, param interface{}) error
- func (c *NatsClient) Request(topic string, param *NatsMessage) (*NatsMessageRsp, error)
- func (c *NatsClient) Response(topic string, param *NatsMessageRsp) error
- func (c *NatsClient) Start()
- func (c *NatsClient) Subscribe(topic string, h HFunc)
- type NatsMessage
- type NatsMessageRsp
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 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 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"` }
Click to show internal directories.
Click to hide internal directories.