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

service framework - metadata options #206

Open
6 of 13 tasks
aricart opened this issue Mar 13, 2023 · 2 comments
Open
6 of 13 tasks

service framework - metadata options #206

aricart opened this issue Mar 13, 2023 · 2 comments
Labels
client Client related work enhancement New feature or request

Comments

@aricart
Copy link
Member

aricart commented Mar 13, 2023

Overview

Micro ADR-32 now allows optional metadata to be specified on the the service and on endpoints. The metadata is simply Record<string,string>.
Note that schema report also includes any metadata associated with the endpoint.

The cross-client test has been updated (on the dev branch) if you are using it, it will flag if metadata is not specified in your test service.

Clients and Tools

Other Tasks

  • docs.nats.io updated @bruth
  • Update ADR to Implemented
  • Update client features spreadsheet

Client authors please update with your progress. If you open issues in your own repositories as a result of this request, please link them to this one by pasting the issue URL in a comment or main issue description.

@giceratops
Copy link

Whilst playing with the metadata in the Java impl I bumped into the following:

I wanted to change/add metadata after the client was created. Seemed to be a nice way to have dynamic info available of each service from the monitor. Without making endpoints, and calling those based on the results of a discovery. Similar like endpoints in stats.

This doesn't work because the ServiceRespsonse gets serialized at the Service constructor with the metadata originally provided at the builder. Atleast, the ones for ping and info do.

For the stats context the story is different. When passing an empty map to the builder it's nulled in the Service constructor, losing the original pointer. But by adding any (garbage) value to the map before building, the Service keeps the pointer to the original map (which then actually comes from the reference of the cached ping ServiceRespsonse before it is seriaziled). This way it is possible to expose some dynamic metadata using just the monitor client in the stats context. But this seems wrong?

Somehow it feels like it makes sense to have ping and info static, where stats is like endpoints. But in that case the isEmpty() should be removed to make its behaviour consistent? Or am I down a wrong path?

@ripienaar
Copy link
Contributor

The metadata describes the service instance it’s not for dynamic use.

We are clarifying that in the spec and will enforce it in the clients.

Additionally we are adding a feature that allows you to build way to create an endpoint that expose your own metadata and that can be queried same as info in a 1;n manner.

See #300 @giceratops

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
client Client related work enhancement New feature or request
Projects
None yet
Development

No branches or pull requests