nats.go
nats.go copied to clipboard
add optional metadata to service
This allows to add optional meta data to a service, for instance, in my case, the services are dispatched across multiple machines, on the edge.
The ability to add meta data like this, and retrieve them in the PING, INFO... is very useful :
// ...
hostname, _ := os.Hostname()
externalIP := getmyip.ViaOpenDNS()
config := micro.Config{
Name: "EchoService",
Version: "1.0.0",
Description: "Send back what you receive",
Meta: map[string]interface{}{
"hostname": hostname,
"external-ip": externalIP,
},
Endpoint: micro.Endpoint{
Subject: "echo",
Handler: echoHandler,
},
// ...
}
svc, err := micro.AddService(nc, config)
// ...
Hi @telemac thanks for the contribution! The services API is fairly new and we are trying to have parity in the clients by following the spec in this ADR: https://github.com/nats-io/nats-architecture-and-design/blob/main/adr/ADR-32.md Could you please send an enhancement request to the spec there with this metadata feature? Then if that is merged other client implementations can follow along too.
Hi @telemac thanks for the contribution! The services API is fairly new and we are trying to have parity in the clients by following the spec in this ADR: https://github.com/nats-io/nats-architecture-and-design/blob/main/adr/ADR-32.md Could you please send an enhancement request to the spec there with this metadata feature? Then if that is merged other client implementations can follow along too.
Thank you @wallyqs, I missed this repo, here is the PR : https://github.com/nats-io/nats-architecture-and-design/pull/182
I'll remove the go.mod changes