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
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
42 changes: 42 additions & 0 deletions adr/ADR-00.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Metadata for Stream and Consumer

|Metadata|Value|
|--------|-----|
|Date |2023-01-23|
|Author |@Jarema|
|Status |Proposed|
Jarema marked this conversation as resolved.
Show resolved Hide resolved
|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 not ergonomic workaround.

## Server PR
https://github.com/nats-io/nats-server/pull/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.

To avoid abuse of the metadata, the size of it will be limited to 1MB.
Jarema marked this conversation as resolved.
Show resolved Hide resolved
Size will be counter for lenght of keys + values.

### Example
```json
{
"durable_name": "consumer",
... // 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 👍

}
}

```