Skip to content

Commit 7b33a9a

Browse files
authored
Merge pull request #29 from tchiotludo/micronaut
Move to Micronaut
2 parents a968011 + 0f26900 commit 7b33a9a

File tree

82 files changed

+1357
-1186
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+1357
-1186
lines changed

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ build/*
1818
.gradletasknamecache
1919

2020
### Assets
21-
public/static
21+
src/main/resources/static
2222
node_modules
2323
node/
2424

@@ -36,7 +36,7 @@ out/*
3636
logs/*
3737

3838
### Kafka HQ ###
39-
conf/*.dev.conf
39+
src/**/*-dev.yml
4040

4141
## Docker
4242
.env

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
FROM openjdk:8-jre-alpine
22
WORKDIR /app
33
COPY docker /
4-
ENTRYPOINT ["docker-entrypoint.sh"]
4+
ENV MICRONAUT_CONFIG_FILES=/app/application.yml
55
CMD ["./kafkahq"]

README.md

Lines changed: 55 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -64,58 +64,78 @@ First you need a [configuration files](#configuration) in order to configure Kaf
6464
```sh
6565
docker run -d \
6666
-p 8080:8080 \
67-
-v /tmp/application.conf:/app/application.conf \
67+
-v /tmp/application.yml:/app/application.yml \
6868
tchiotludo/kafkahq
6969
```
70-
* With `-v /tmp/application.conf` must be an absolute path to configuration file
70+
* With `-v /tmp/application.yml` must be an absolute path to configuration file
7171
* Go to http://localhost:8080
7272

7373

7474
### Stand Alone
7575

7676
* Install Java 8
7777
* Download the latest jar on [release page](https://github.com/tchiotludo/kafkahq/releases)
78-
* Create an `application.conf` in the same directory
79-
* Launch the application with `java -jar kafkahq.jar prod`
78+
* Create an [configuration files](#configuration)
79+
* Launch the application with `java -Dmicronaut.config.files=/path/to/application.yml -jar kafkahq.jar`
8080
* Go to http://localhost:8080
8181

8282

8383
## Configuration
84-
Configuration file is a [HOCON configuration](https://github.com/lightbend/config/blob/master/HOCON.md) file with an example below :
85-
```
86-
{
87-
kafka {
88-
connections {
89-
my-cluster-1 {
90-
properties {
91-
bootstrap.servers: "kafka:9092"
92-
}
93-
registry: "http://schema-registry:8085"
94-
}
95-
my-cluster-2 {
96-
properties {
97-
bootstrap.servers: "kafka:9093"
98-
security.protocol: SSL
99-
ssl.truststore.location: /app/truststore.jks
100-
ssl.truststore.password: password
101-
ssl.keystore.location: /app/keystore.jks
102-
ssl.keystore.password: password
103-
ssl.key.password: password
104-
}
105-
}
106-
}
107-
}
108-
}
84+
Configuration file can by default be provided in either Java properties, YAML, JSON or Groovy files.
85+
Configuration file example in YML :
86+
87+
```yml
88+
kafkahq:
89+
server:
90+
# if behind a reverse proxy, path to kafkahq with trailing slash
91+
base-path: ""
92+
93+
# default kafka properties for each clients, available for admin / producer / consumer (optionnal)
94+
clients-defaults:
95+
consumer:
96+
properties:
97+
isolation.level: read_committed
98+
99+
# list of kafka cluster available for kafkahq
100+
connections:
101+
# url friendly name for the cluster
102+
my-cluster-1:
103+
# standard kafka properties (optionnal)
104+
properties:
105+
bootstrap.servers: "kafka:9092"
106+
# schema registry url (optionnal)
107+
schema-registry: "http://schema-registry:8085"
108+
109+
my-cluster-2:
110+
properties:
111+
bootstrap.servers: "kafka:9093"
112+
security.protocol: SSL
113+
ssl.truststore.location: /app/truststore.jks
114+
ssl.truststore.password: password
115+
ssl.keystore.location: /app/keystore.jks
116+
ssl.keystore.password: password
117+
ssl.key.password: password
118+
119+
topic-data:
120+
# default sort order (OLDEST, NEWEST)
121+
sort: OLDEST
122+
# max record per page
123+
size: 50
109124
```
110125
111-
`kafka.connections` is a key value configuration with :
112-
* `key`: must be an url friendly string the identify your cluster (`my-cluster-1` and `my-cluster-2` is the example above)
113-
* `properties`: all the configurations found on [Kafka consumer documentation](https://kafka.apache.org/documentation/#consumerconfigs). Most important is `bootstrap.servers` that is a list of host:port of your Kafka brokers.
114-
* `registry`: the schema registry url *(optional)*
126+
* `kafkahq.server.base-path`: if behind a reverse proxy, path to kafkahq with trailing slash
127+
* `kafkahq.clients-defaults.{{admin|producer|consumer}}.properties`: if behind a reverse proxy, path to kafkahq with trailing slash
128+
* `kafkahq.connections` is a key value configuration with :
129+
* `key`: must be an url friendly string the identify your cluster (`my-cluster-1` and `my-cluster-2` is the example above)
130+
* `properties`: all the configurations found on [Kafka consumer documentation](https://kafka.apache.org/documentation/#consumerconfigs). Most important is `bootstrap.servers` that is a list of host:port of your Kafka brokers.
131+
* `schema-registry`: the schema registry url *(optional)*
115132

116-
KafkaHQ docker image support 1 environment variables to handle configuraiton :
117-
* `KAFKAHQ_CONFIGURATION`: a string that contains the full configuration that will be written on /app/configuration.conf on container.
133+
> Since KafkaHQ is based on [Micronaut](https://micronaut.io/), you can customize configurations (server port, ssl, ...) with [Micronaut configuration](https://docs.micronaut.io/snapshot/guide/configurationreference.html#io.micronaut.http.server.HttpServerConfiguration).
134+
> More information can be found on [Micronaut documentation](https://docs.micronaut.io/snapshot/guide/index.html#config)
118135

136+
KafkaHQ docker image support 2 environment variables to handle configuraiton :
137+
* `MICRONAUT_APPLICATION_JSON`: a string that contains the full configuration in JSON format
138+
* `MICRONAUT_CONFIG_FILES`: a path to to a configuration file on container. Default path is `/app/application.yml`
119139

120140
## Development Environment
121141
A docker-compose is provide to start a development environnement.

assets/modules/datas/search-sse.js

Lines changed: 16 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -38,28 +38,26 @@ $.widget("khq.search-sse", $.khq.widget, {
3838
this._eventSource.addEventListener('searchBody', function(e) {
3939
let searchBody = JSON.parse(e.data);
4040

41-
if (searchBody.body.trim()) {
41+
if (searchBody.body) {
4242
table.append(searchBody.body);
4343
$(document).trigger('khq.refresh');
4444
}
4545

46-
if (searchBody.progress && searchBody.offsets) {
47-
self._updateProgress(searchBody.offsets, searchBody.progress)
46+
if (searchBody.after !== null) {
47+
self._updateAfter(searchBody.percent);
48+
}
49+
50+
if (searchBody.percent) {
51+
self._updateProgressBar(searchBody.percent);
4852
}
4953
}, false);
5054

5155
this._eventSource.addEventListener("searchEnd", function(e) {
5256
self._close(e);
5357
let searchEnd = JSON.parse(e.data);
5458

55-
if (searchEnd.after !== null) {
56-
self._after
57-
.removeClass('disabled')
58-
.find('.page-link')
59-
.attr('href', self._url().setSearch("after", searchEnd.after));
60-
} else {
61-
self._updateProgressBar(100);
62-
}
59+
self._updateAfter(searchEnd.percent);
60+
self._updateProgressBar(100);
6361
});
6462
},
6563

@@ -68,24 +66,16 @@ $.widget("khq.search-sse", $.khq.widget, {
6866
this._cancelButton.addClass('disabled btn-outline-dark');
6967
},
7068

71-
_updateProgress(offsets, progress) {
72-
let current = 0;
73-
let total = 0;
74-
75-
$.each(offsets, function (partition, offset) {
76-
total += offset.end - offset.begin;
77-
});
78-
79-
$.each(progress, function (partition, remaining) {
80-
current += remaining;
81-
});
82-
83-
this._updateProgressBar(100-(current*100/total));
84-
},
85-
8669
_updateProgressBar(number) {
8770
this._progressBar
8871
.css('width', number + "%")
8972
.text((Math.round(number * 100) / 100) + "%");
73+
},
74+
75+
_updateAfter(after) {
76+
this._after
77+
.removeClass('disabled')
78+
.find('.page-link')
79+
.attr('href', this._url().setSearch("after", after));
9080
}
9181
});

0 commit comments

Comments
 (0)