Client lib for nats.io.
struct MSG {
mut:
subid string
pub mut:
subject string
msg string
size int
}
struct Nats {
pub mut:
verbose bool
pedantic bool
echo bool
mut:
url string
user string
pass string
lastid int
handlers shared map[string]SubjectHandler
inch chan string
inmsg chan MSG
info json2.Any
connected bool
c net.TcpConn
}
fn (mut n Nats) connect(url string, user string, pass string) ?
Connect to nats server.
fn (mut n Nats) close() ?
Close connection.
fn (mut n Nats) sub(subject string, cb SubjectHandler) ?string
Subscribe to subject.
fn (mut n Nats) usub(subid string) ?
Unsubscribe to subject.
fn (mut n Nats) publish(subject string, msg string) ?
Publish message.