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
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions jetstream/kv.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,52 +197,52 @@ type (
// Bucket is the name of the KeyValue store. Bucket name has to be
// unique and can only contain alphanumeric characters, dashes, and
// underscores.
Bucket string
Bucket string `json:"bucket"`

// Description is an optional description for the KeyValue store.
Description string
Description string `json:"description,omitempty"`

// MaxValueSize is the maximum size of a value in bytes. If not
// specified, the default is -1 (unlimited).
MaxValueSize int32
MaxValueSize int32 `json:"max_value_size,omitempty"`

// History is the number of historical values to keep per key. If not
// specified, the default is 1. Max is 64.
History uint8
History uint8 `json:"history,omitempty"`

// TTL is the expiry time for keys. By default, keys do not expire.
TTL time.Duration
TTL time.Duration `json:"ttl,omitempty"`

// MaxBytes is the maximum size in bytes of the KeyValue store. If not
// specified, the default is -1 (unlimited).
MaxBytes int64
MaxBytes int64 `json:"max_bytes,omitempty"`

// Storage is the type of storage to use for the KeyValue store. If not
// specified, the default is FileStorage.
Storage StorageType
Storage StorageType `json:"storage,omitempty"`

// 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:"num_replicas,omitempty"`

// Placement is used to declare where the stream should be placed via
// tags and/or an explicit cluster name.
Placement *Placement
Placement *Placement `json:"placement,omitempty"`

// RePublish allows immediate republishing a message to the configured
// subject after it's stored.
RePublish *RePublish
RePublish *RePublish `json:"republish,omitempty"`

// Mirror defines the consiguration for mirroring another KeyValue
// store.
Mirror *StreamSource
Mirror *StreamSource `json:"mirror,omitempty"`

// Sources defines the configuration for sources of a KeyValue store.
Sources []*StreamSource
Sources []*StreamSource `json:"sources,omitempty"`

// Compression sets the underlying stream compression.
// NOTE: Compression is supported for nats-server 2.10.0+
Compression bool
Compression bool `json:"compression,omitempty"`
}

// KeyLister is used to retrieve a list of key value store keys. It returns
Expand Down
26 changes: 13 additions & 13 deletions kv.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,22 +249,22 @@ func purge() DeleteOpt {

// KeyValueConfig is for configuring a KeyValue store.
type KeyValueConfig struct {
Bucket string
Description string
MaxValueSize int32
History uint8
TTL time.Duration
MaxBytes int64
Storage StorageType
Replicas int
Placement *Placement
RePublish *RePublish
Mirror *StreamSource
Sources []*StreamSource
Bucket string `json:"bucket"`
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!

MaxBytes int64 `json:"max_bytes,omitempty"`
Storage StorageType `json:"storage,omitempty"`
Replicas int `json:"num_replicas,omitempty"`
Placement *Placement `json:"placement,omitempty"`
RePublish *RePublish `json:"republish,omitempty"`
Mirror *StreamSource `json:"mirror,omitempty"`
Sources []*StreamSource `json:"sources,omitempty"`

// Enable underlying stream compression.
// NOTE: Compression is supported for nats-server 2.10.0+
Compression bool
Compression bool `json:"compression,omitempty"`
}

// Used to watch all keys.
Expand Down