Skip to content

Headers on kv entries #278

@cjohansen

Description

@cjohansen

Paraphrase

The question here is two-fold.

  1. Could (should) the KV api be expanded to allow putting headers as well the value with a key.
  2. Is it safe for a custom implementation to put headers on, or is there a technical reason why the headers space on the message should be reserved for internal future use.

Original

I have a question, hope this is the right place to ask.

Is it OK to set custom headers on kv entries? I'm working on a Clojure client (https://github.com/cjohansen/clj-nats/), and one of my goals is for it to work seemlessly with Clojure's immutable data structures. For streams I have implemented the client such that if you write message with a Clojure data structure in the message body, the client adds a content-type header to the message. When the message is read back, it can be automatically parsed as Clojure data when the relevant content-type is set on the message.

I've experimented with the same feature for kv entries, and it works, but I wanted to make sure that doing this is safe and will continue to work. It allows the client to work like so:

(kv/put conn "kv-bucket" "key1" {:name "Mr Bojangle"})

(kv/get conn "kv-bucket" "key1")
;;=> {:name "Mr Bojangle"}

So: Is it OK to add custom headers to kv entry messages?

Metadata

Metadata

Labels

documentationImprovements or additions to documentationenhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions