Skip to content

Commit

Permalink
docs: Add simple explanation (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
sverrehu authored Oct 5, 2023
1 parent 55f7b2d commit 9e278e0
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1 +1,44 @@
# k3a-embedded

Embedded Kafka server for running simple integration tests. Embedded
in the sense that the Kafka server is running in the same VM as the
tests. No container runtime required.

## Limitations

* Not at all configurable. Starts a single-node server with no
security at all.
* No Zookeeper. The server runs in KRaft mode.

## What it does

* Creates a temporary directory that will hold all runtime files of
Kafka. This directory is deleted when the server is stopped.
* Finds a random available port that the broker will listen to.

## Usage

For JUnit tests, do something like this for starting, stopping, and
getting the correct Kafka bootstrap servers (the latter will be
`localhost` in combination with the random port):

```java
private static K3aEmbedded kafka;

@BeforeClass
public static void beforeClass() {
kafka = new K3aEmbedded();
kafka.start();
}

@AfterClass
public static void afterClass() {
kafka.stop();
}

private Map<String, Object> getCommonConfig() {
final Map<String, Object> map = new HashMap<>();
map.put(CommonClientConfigs.BOOTSTRAP_SERVERS_CONFIG, kafka.getBootstrapServers());
return map;
}
```

0 comments on commit 9e278e0

Please sign in to comment.