v0.12.0
This release is an effort toward better stability of the JavaScript API. As you will see in the following changelog, most of the changes are refactorings, as I envisioned in #89. I completely revamped the API, removed the old ones, and introduced better ones with a more native JavaScript syntax. These are the changes:
- Better JS API docs with all the constants, classes, and data structures, all documented here.
- Better logging with the ability to connect the global extension logger to the
Reader
and/orWriter
objects (of the kafka-go library) to print the internal errors by using theconnectLogger
parameter. - Better error handling by throwing exceptions (native to JS) rather than returning them (native to Go), so you can enclose them in try/catch blocks.
- All constants are now available for import at the module level and there are lots of them for different purposes.
- The
writer
andreader
functions are removed, and replaced by classes that can be instantiated like this:import { Writer, Reader } from "k6/x/kafka"; const writer = new Writer({ brokers: ["localhost:9092"], topic: "my-topic", autoCreateTopic: true, }); const reader = new Reader({ brokers: ["localhost:9092"], topic: "my-topic", });
- The
produce
andconsume
functions are now methods of their respectiveWriter
andReader
classes:writer.produce({ messages: [ { key: "key", value: "value", } ] }); const messages = reader.consume({limit: 10});
- Constructors' and methods' parameters are now JSON objects, mostly.
- All the kafka-go's
WriterConfig
andReaderConfig
are now combined and consolidated, and they are available as parameters to theWriter
andReader
objects, so everything is customizable now. Only some of them are tested, though. So, feel free to open an issue if you find any. - Topic-related functions are now exposed in a
Connection
class. You need to instantiate the class in theinit
context and use its methods for listing, creating, and deleting topics.import { Connection } from "k6/x/kafka"; const connection = new Connection({ address: "localhost:9092" }); connection.listTopics(); connection.createTopic({ topic: "my-topic" }); connection.deleteTopic("my-topic");
- All the scripts are now updated with the new syntax.
- A few bugs are fixed and dependencies are updated.
I hope you like the new changes and please report issues if you find any.
What's Changed
- Refactor logging by @mostafa in #90
- Export all constants to JS code by @mostafa in #91
- Export a proper constructor by @mostafa in #92
- Throw an exception instead of returning an error by @mostafa in #93
- Call a method on an object, instead of passing the object to a function by @mostafa in #95
- Pass constructor arguments as a single JSON object by @mostafa in #96
- Consolidate options by @mostafa in #97
- Create Connection class and methods for creating, deleting, and listing topics by @mostafa in #98
- Update JS API docs by @mostafa in #99
- Fix script errors by adding
connection.createTopic
by @mostafa in #100 - Fix header retrieval when consuming messages by @mostafa in #101
- Ignore
noTLSConfig
error code, because it is polluting the output log by @mostafa in #103 - Update README for the big release by @mostafa in #102
- Update dependencies by @mostafa in #104
- Add a new logo and update README by @mostafa in 5e2b4ab 37ebfb5 2ddfa1d
Full Changelog: v0.11.0...v0.12.0