THIS IS A TEST INSTANCE. ALL YOUR CHANGES WILL BE LOST!!!!
...
- Add a new headers length and value (byte[]) to the core message format.
- Create a Header Interface and implementing class
Interface
Code Block public interface Header { String key(); byte[] value(); }
Implementation Detail
- Add a String key field to Header implementing class
Add a byte[] value field to Header implementing class
- Create a Headers Interface and implementing class
- Headers will be mutable
- For the Producer, after send and post interceptors it will be turned into a read only immutable instance.
- This will be done by calling "close()" method
Interface
Code Block public interface Headers extends Iterable<Header> { /** * Adds a header (key inside), returning if the operation succeeded. * If headers is in read-only, will always fail the operation with throwing IllegalStateException. */ Headers add(Header header) throws IllegalStateException; /** * Removes ALL HEADERS for the given key returning if the operation succeeded. * If headers is in read-only, will always fail the operation with throwing IllegalStateException. */ Headers remove(String key) throws IllegalStateException; /** * Returns JUST ONE (the very last) header for the given key, if present. */ Header header(String key) /** * Returns ALL headers for the given key, if present. */ Iterable<Header> headers(String key); /** * Turns the mutable instance into read only immutable instance, * this is invoked on send after the interceptors. */ Headers close(); }
Implementation Detail
Add accessor methods on the Headers class
- Headers add(Header header)
- Headers remove(Header header)
- Header header(String key)
- Iterable<Header> headers(String key)
- Inline with ConsumerRecords interface returning the subset of ConsumerRecord for a given topic.
- public Iterable<ConsumerRecord<K, V>> records(String topic)
- Inline with ConsumerRecords interface returning the subset of ConsumerRecord for a given topic.
- implement Iterable<Header>
- interceptors are expected to add headers during the produce intercept stage.
- Headers will be mutable
- Add a headers field to ProducerRecord and ConsumerRecord.
- Add constructor(s) of Producer/ConsumerRecord to allow passing in of Iterable<Header>
- use case is MirrorMakers able to copy headers.
- Add accessor methods on the Producer/ConsumerRecord Headers headers()
Code Block public class ProducerRecord<K, V> { ... ProducerRecord(K key, V value, Iterable<Header> headers, ...) ... public Headers headers(); ... }
Code Block public class ConsumerRecord<K, V> { ... ConsumerRecord(K key, V value, Iterable<Header> headers, ...) ... public Headers headers(); ... }
- Changes needed, will piggyback onto V3 of ProduceRequest and V4 of FetchRequest which were introduced in KIP-98
- The serialisation of the [String, byte[]] header array will on the wire using a strict format
- Each headers value will be custom serialisable by the interceptors/plugins that use the header.
...