Skip to content

v0.12.0

Compare
Choose a tag to compare
@github-actions github-actions released this 02 Jul 21:02
· 132 commits to main since this release
d205d0b

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:

  1. Better JS API docs with all the constants, classes, and data structures, all documented here.
  2. Better logging with the ability to connect the global extension logger to the Reader and/or Writer objects (of the kafka-go library) to print the internal errors by using the connectLogger parameter.
  3. 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.
  4. All constants are now available for import at the module level and there are lots of them for different purposes.
  5. The writer and reader 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",
    });
  6. The produce and consume functions are now methods of their respective Writer and Reader classes:
    writer.produce({
      messages: [
        {
          key: "key",
          value: "value",
        }
      ]
    });
    
    const messages = reader.consume({limit: 10});
  7. Constructors' and methods' parameters are now JSON objects, mostly.
  8. All the kafka-go's WriterConfig and ReaderConfig are now combined and consolidated, and they are available as parameters to the Writer and Reader objects, so everything is customizable now. Only some of them are tested, though. So, feel free to open an issue if you find any.
  9. Topic-related functions are now exposed in a Connection class. You need to instantiate the class in the init 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");
  10. All the scripts are now updated with the new syntax.
  11. 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

Full Changelog: v0.11.0...v0.12.0