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

[UPDATED] Added json tags to KeyValueConfig struct to behave consistently with the StreamConfig one #1630

Merged
merged 3 commits into from
May 16, 2024

Conversation

pricelessrabbit
Copy link
Contributor

This PR add json tags to the KeyValueConfig struct like the ones already present in StreamConfig.
This is useful when working with KV buckets because currently you need a map or support struct to marshal / unmarshal a bucket config to / from JSON.

  • I used the StreamConfig tags as reference.
  • I replicated the omitempty option for the fields that have it in StreamConfig, but a check is needed for the other ones.

Signed-off-by: Mattia Barbisan <pricelessrabbit@gmail.com>
@piotrpio piotrpio self-requested a review May 13, 2024 12:24
Copy link
Collaborator

@piotrpio piotrpio left a comment

Choose a reason for hiding this comment

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

Thanks for the PR! I have one suggestion regarding the tag name.

Other than that, I don't think omitempty matters a lot in that case since we never really serialize the config from within the library. If anything, I would probably use omitempty to represent optionality of those fields, similarly to how we have it in object store - i.e. only bucket name would not have it.

jetstream/kv.go Outdated

// Replicas is the number of replicas to keep for the KeyValue store in
// clustered jetstream. Defaults to 1, maximum is 5.
Replicas int
Replicas int `json:"replicas"`
Copy link
Collaborator

Choose a reason for hiding this comment

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

To be consistent with stream config, this should probably be num_replicas

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i just pushed the fix with num_replicas and also changed omitempty like the object storage ones 🐰

- udpated "omitempty" options to match the object store config ones

Signed-off-by: Mattia Barbisan <pricelessrabbit@gmail.com>
Copy link
Collaborator

@piotrpio piotrpio left a comment

Choose a reason for hiding this comment

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

Looks good, just one more nit I only noticed now.

kv.go Outdated
Description string `json:"description,omitempty"`
MaxValueSize int32 `json:"max_value_size,omitempty"`
History uint8 `json:"history,omitempty"`
TTL time.Duration `json:"ttl,omitempty,omitempty"`
Copy link
Collaborator

Choose a reason for hiding this comment

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

Sorry about that, I did not notice at first, you have doubled omitempty here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sry, fixed!

Signed-off-by: Mattia Barbisan <pricelessrabbit@gmail.com>
Copy link
Collaborator

@piotrpio piotrpio left a comment

Choose a reason for hiding this comment

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

LGTM, thank you for the contribution!

@piotrpio piotrpio merged commit ff188f2 into nats-io:main May 16, 2024
1 check passed
@piotrpio piotrpio mentioned this pull request May 17, 2024
piotrpio pushed a commit that referenced this pull request Aug 15, 2024
…ntly with the StreamConfig one (#1630)

Signed-off-by: Mattia Barbisan <pricelessrabbit@gmail.com>
piotrpio pushed a commit that referenced this pull request Aug 15, 2024
…ntly with the StreamConfig one (#1630)

Signed-off-by: Mattia Barbisan <pricelessrabbit@gmail.com>
piotrpio pushed a commit that referenced this pull request Dec 13, 2024
…ntly with the StreamConfig one (#1630)

Signed-off-by: Mattia Barbisan <pricelessrabbit@gmail.com>
piotrpio pushed a commit that referenced this pull request Dec 13, 2024
…ntly with the StreamConfig one (#1630)

Signed-off-by: Mattia Barbisan <pricelessrabbit@gmail.com>
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.

2 participants