Release: go-res v0.4.0

Apart from the release of Resgate v1.6.0, the Go package, go-res, has also gotten a new release.

It contains support for the new protocol features, soft references and data values, introduced in Resgate v1.6.0. But it also comes with some additional features:

Package resprot

The resprot subpackage provides low level structs and methods for communicating with other services over NATS server:

Make a request

conn, _ := nats.Connect("nats://127.0.0.1:4222")
response := resprot.SendRequest(conn, "call.example.ping", nil, time.Second)

Get a model

response := resprot.SendRequest(conn, "get.example.model", nil, time.Second)

var model struct {
	Message string `json:"message"`
}
_, err := response.ParseModel(&model)

Call a method

response := resprot.SendRequest(conn, "call.math.add", resprot.Request{Params: struct {
	A float64 `json:"a"`
	B float64 `json:"b"`
}{5, 6}}, time.Second)

var result struct {
	Sum float64 `json:"sum"`
}
err := response.ParseResult(&result)

QueueChanSubscribe support

To allow better horizontal scaling when only using system.reset to update resources, go-res now by default uses nats’ QueueChanSubscribe (instead of just ChanSubscribe ). This is configurable, but will by default use the service name as queue group.

Thanks to @raphaelpereira for pioneering this approach for horizontal scaling!

Release notes

1 Like