How to use protobuf encoder/decoder #919
-
I have a simple Just for reference, this is my basic function to connect to Nats: func Connect() (*nats.EncodedConn, error) {
cluster, exists := os.LookupEnv("NATS_CLUSTER")
if !exists {
return nil, errors.New("nats connection url not defined")
}
nc, err := nats.Connect(cluster)
if err != nil {
return nil, err
}
c, err := nats.NewEncodedConn(nc, "protobuf")
if err != nil {
// no encoder registered for 'protobuf'
return nil, err
}
return c, nil
} |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
https://github.com/nats-io/nats.go/blob/main/test/protobuf_test.go |
Beta Was this translation helpful? Give feedback.
https://github.com/nats-io/nats.go/blob/main/test/protobuf_test.go