/
topics.go
33 lines (29 loc) · 893 Bytes
/
topics.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package nxcore
import "github.com/jaracil/ei"
// TopicSubscribe subscribes a pipe to a topic.
// Returns the response object from Nexus or error.
func (nc *NexusConn) TopicSubscribe(pipe *Pipe, topic string) (interface{}, error) {
par := ei.M{
"pipeid": pipe.Id(),
"topic": topic,
}
return nc.Exec("topic.sub", par)
}
// TopicUnsubscribe unsubscribes a pipe from a topic.
// Returns the response object from Nexus or error.
func (nc *NexusConn) TopicUnsubscribe(pipe *Pipe, topic string) (interface{}, error) {
par := ei.M{
"pipeid": pipe.Id(),
"topic": topic,
}
return nc.Exec("topic.unsub", par)
}
// TopicPublish publishes message to a topic.
// Returns the response object from Nexus or error.
func (nc *NexusConn) TopicPublish(topic string, msg interface{}) (interface{}, error) {
par := ei.M{
"topic": topic,
"msg": msg,
}
return nc.Exec("topic.pub", par)
}