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 metadata ADR #194

Merged
merged 6 commits into from Jan 24, 2023
Merged

Add metadata ADR #194

merged 6 commits into from Jan 24, 2023

Conversation

Jarema
Copy link
Member

@Jarema Jarema commented Jan 21, 2023

Metadata for Stream and Consumer

Metadata Value
Date 2023-01-23
Author @Jarema
Tags jetstream, client, server

Context and Problem Statement

Until now, there was no way to easily add additional information about Stream or Consumer.
The only solution was using Description field, which is a ugly workaround.

Server PR

nats-io/nats-server#3797

Design

The solution is to add new metadata field to both Consumer and Stream config.
The metadata field would by a map of string keys and string values.

The map would be represented in json as object with nested key/value pairs, which is a default
way to marshal maps/hashmaps in most languages.

Example

{
  "durable_name": "consumer",
  ... // other consumer/stream fields
  "metadata": {
    "owner": "nack",
    "domain": "product"
  }
}

Open questions

Do we want to limit the size of metadata?

Signed-off-by: Tomasz Pietrek tomasz@nats.io

Signed-off-by: Tomasz Pietrek <tomasz@nats.io>
Signed-off-by: Tomasz Pietrek <tomasz@nats.io>
adr/ADR-00.md Outdated Show resolved Hide resolved
adr/ADR-00.md Outdated
... // other consumer/stream fields
"metadata": {
"owner": "nack",
"domain": "product"
Copy link
Member

@wallyqs wallyqs Jan 23, 2023

Choose a reason for hiding this comment

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

considering we could add some private internal metadata namespace when it starts with underscore like "_created_nats_version":"2.10.0" that is immutable and we can pinpoint the origin of the objects for debugging, also via the metadata fields would be useful to stamp whether it was created for a KV/ObjectStore usage for example as a hint for debugging and troubleshooting.

Copy link
Member Author

Choose a reason for hiding this comment

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

The internal namespace is a good idea!

Maybe _nats ?

Those could be use by both client internals and the server.
Server could ensure immutability of its entries.

Copy link
Member

Choose a reason for hiding this comment

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

_nats sounds good 👍

Signed-off-by: Tomasz Pietrek <tomasz@nats.io>
@Jarema
Copy link
Member Author

Jarema commented Jan 23, 2023

Improved ADR after discussions:

  1. Set limit to 128kB
  2. Added reserved prefix for internals _nats.

Signed-off-by: Tomasz Pietrek <tomasz@nats.io>
adr/ADR-00.md Outdated Show resolved Hide resolved
adr/ADR-00.md Outdated Show resolved Hide resolved
adr/ADR-00.md Outdated Show resolved Hide resolved
Signed-off-by: Tomasz Pietrek <tomasz@nats.io>
@Jarema
Copy link
Member Author

Jarema commented Jan 24, 2023

@ripienaar @wallyqs ADR updated, PR updated.

Copy link
Contributor

@ripienaar ripienaar left a comment

Choose a reason for hiding this comment

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

LGTM

Signed-off-by: Tomasz Pietrek <tomasz@nats.io>
@Jarema Jarema changed the title Add metadata ADR proposal Add metadata ADR Jan 24, 2023
@Jarema Jarema merged commit 282b9b4 into main Jan 24, 2023
@wallyqs wallyqs deleted the jarema/add-stream-consumer-metadata branch January 26, 2023 01:21
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

4 participants