Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add optional metadata to service #1170

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

Conversation

telemac
Copy link

@telemac telemac commented Dec 23, 2022

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

@wallyqs
Copy link
Member

wallyqs commented Dec 23, 2022

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.

go.mod Outdated
@@ -3,6 +3,9 @@ module github.com/nats-io/nats.go
go 1.16

require (
github.com/golang/protobuf v1.5.0
github.com/nats-io/nats-server/v2 v2.9.10 // indirect
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We keep testing dependencies outside of this go.mod by running tests with another modfile in this repo like this:

go test -modfile=go_test.mod 

@telemac
Copy link
Author

telemac commented Dec 23, 2022

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 : nats-io/nats-architecture-and-design#182

I'll remove the go.mod changes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants