forked from tchiotludo/akhq
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d05a4cc
commit a1a1eb4
Showing
60 changed files
with
845 additions
and
793 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
profile: service | ||
defaultPackage: org.kafkahq | ||
--- | ||
testFramework: junit | ||
sourceLanguage: java |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,91 +1,30 @@ | ||
package org.kafkahq; | ||
|
||
import com.typesafe.config.Config; | ||
import org.jooby.FlashScope; | ||
import org.jooby.Jooby; | ||
import org.jooby.RequestLogger; | ||
import org.jooby.assets.Assets; | ||
import org.jooby.ftl.Ftl; | ||
import org.jooby.json.Jackson; | ||
import org.jooby.livereload.LiveReload; | ||
import org.jooby.whoops.Whoops; | ||
import org.kafkahq.controllers.*; | ||
import org.kafkahq.modules.KafkaModule; | ||
import org.kafkahq.modules.KafkaWrapper; | ||
import org.kafkahq.repositories.AbstractRepository; | ||
import io.micronaut.runtime.Micronaut; | ||
|
||
import java.nio.file.Path; | ||
import java.nio.file.Paths; | ||
import java.util.Optional; | ||
|
||
public class App extends Jooby { | ||
// module | ||
public class App { | ||
// route | ||
{ | ||
use(new FlashScope()); | ||
/* | ||
use(new Whoops()); | ||
use("*", new RequestLogger() | ||
.latency() | ||
.extended() | ||
); | ||
use(new Jackson()); | ||
|
||
on("dev", () -> { | ||
Path basedir = Paths.get(System.getProperty("user.dir")); | ||
use(new Whoops()); | ||
use(new LiveReload() | ||
.register(basedir.resolve("public"), | ||
"**/*.ftl" | ||
) | ||
.register(basedir.resolve("target"), | ||
"**/*.class", | ||
"**/*.conf", | ||
"**/*.properties") | ||
.register(basedir.resolve("build"), | ||
"**/*.class", | ||
"**/*.conf", | ||
"**/*.properties") | ||
); | ||
}); | ||
on("prod", () -> { | ||
use(new Assets()); | ||
}); | ||
assets("/favicon.ico"); | ||
use(new Ftl("/", ".ftl")); | ||
use(KafkaModule.class); | ||
|
||
// @RequestScoped hack | ||
use("*", "/{cluster}/**", (req, rsp, chain) -> { | ||
Optional<String> cluster = req.param("cluster").toOptional(); | ||
cluster.ifPresent(clusterId -> | ||
AbstractRepository.setWrapper(new KafkaWrapper(this.require(KafkaModule.class), clusterId)) | ||
); | ||
|
||
chain.next(req, rsp); | ||
}); | ||
} | ||
|
||
// route | ||
{ | ||
use("*", "/", (req, rsp, chain) -> { | ||
rsp.redirect("/" + this.require(KafkaModule.class).getClustersList().get(0) + "/topic"); | ||
}); | ||
use("*", "/{cluster}", (req, rsp, chain) -> { | ||
rsp.redirect("/" + req.param("cluster").value() + "/topic"); | ||
}); | ||
use(NodeController.class); | ||
use(SchemaController.class); | ||
use(TopicController.class); | ||
use(GroupController.class); | ||
sse("/{cluster}/topic/{topic}/search/{search}", new DataSseController()); | ||
} | ||
|
||
public static String getBasePath(Config config) { | ||
return config.getString("application.path").replaceAll("/$",""); | ||
*/ | ||
} | ||
|
||
public static void main(String[] args) { | ||
run(App::new, args); | ||
Micronaut.run(App.class); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package org.kafkahq.configs; | ||
|
||
import io.micronaut.context.annotation.Parameter; | ||
import io.micronaut.core.convert.format.MapFormat; | ||
import lombok.Getter; | ||
|
||
import java.util.Map; | ||
|
||
@Getter | ||
abstract public class AbstractProperties { | ||
private final String name; | ||
|
||
@MapFormat(transformation = MapFormat.MapTransformation.FLAT) | ||
Map<String, String> properties; | ||
|
||
public AbstractProperties(@Parameter String name) { | ||
this.name = name; | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package org.kafkahq.configs; | ||
|
||
import io.micronaut.context.annotation.EachProperty; | ||
import io.micronaut.context.annotation.Parameter; | ||
import lombok.Getter; | ||
|
||
import java.net.URL; | ||
import java.util.Optional; | ||
|
||
@EachProperty("kafka.connections") | ||
@Getter | ||
public class Connection extends AbstractProperties { | ||
Optional<URL> registry = Optional.empty(); | ||
|
||
public Connection(@Parameter String name) { | ||
super(name); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package org.kafkahq.configs; | ||
|
||
import io.micronaut.context.annotation.EachProperty; | ||
import io.micronaut.context.annotation.Parameter; | ||
import lombok.Getter; | ||
|
||
@EachProperty("kafka.defaults") | ||
@Getter | ||
public class Default extends AbstractProperties { | ||
public Default(@Parameter String name) { | ||
super(name); | ||
} | ||
} | ||
|
Oops, something went wrong.