nats.go icon indicating copy to clipboard operation
nats.go copied to clipboard

add optional metadata to service

Open telemac opened this issue 2 years ago • 2 comments

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)
	// ...

telemac avatar Dec 23 '22 15:12 telemac

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.

wallyqs avatar Dec 23 '22 17:12 wallyqs

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

telemac avatar Dec 23 '22 19:12 telemac